How do I change an object's layer based on Sine's value

Get help using Construct 2

Post » Mon Oct 19, 2015 8:03 pm

Hi,

I'm trying to achieve an effect where a little object will turn around another object (in false 3D). To do this I put an horizontal sine, a slight vertical sine (same period), and Im trying to change the moving object's layer based on the value of the horizontal sine. Here is what my code looks like :

for an amplitude of 100

object.sine.value <-99 set object to layer 0
object.sine.value >99 set object to layer 2

Of course my other object is on layer 1, so the first one should "turn" around it.

It seems pretty straightforward but the result is not convincing at all. Actually the moving object often passes 2 times before the other one, sometimes it switches layer in the middle of the movement.

I also tried to change the layer based on X value of the moving object, but the result is not better.

Am I missing something with the way sine's value works?

Thanks in advance!
B
29
S
6
G
1
Posts: 347
Reputation: 2,725

Post » Mon Oct 19, 2015 8:24 pm

Should work, but maybe try using 98 instead of 99

Not sure why you use layers and not just z-order?
Move to bottom of layer and Move to top of layer,
or Move to object (behind and in front of)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Oct 19, 2015 8:58 pm

Indeed, I use Z-order now (move to object) and it seems simpler. thanks for the tip! :)
However, it still doesn't work and I guess I know why. I simplified the code, saying that there was one object but there is actually more objects turning at the same time. 6 of them most of the time.

But actually I need to use "compare two values" to be able to check the value of the sine (I don't think it's available in the object condition), so my guess is that maybe the correct instance is not selected when I'm asking to check the sine's value.

In other words, does "compare two values" select only the object instance which conditions are met within it, or doesn't it select anything at all?

If it selects nothing, any way I could achieve what I want to do (i.e. changing the z-order of the object instance(s) which sine's value is close to their max value)?
B
29
S
6
G
1
Posts: 347
Reputation: 2,725

Post » Mon Oct 19, 2015 9:26 pm

system compare doesn't pick anything..

you could try using pick object by comparison..
I guess using a for each object would work too
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Oct 20, 2015 3:23 am

Works perfectly now, thanks a lot!

And here is the final effect. ;)

http://giphy.com/gifs/game-healers-ques ... 1qhQp5sa4g
B
29
S
6
G
1
Posts: 347
Reputation: 2,725


Return to How do I....?

Who is online

Users browsing this forum: Lancifer, Nicolas951, Shenkai the ssj and 25 guests