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

0 favourites
  • 5 posts
From the Asset Store
Advanced inventory mechanics for your RPG game (Array-based). Take Items, split them, pick up them, read the description
  • 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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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)

  • 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)?

  • system compare doesn't pick anything..

    you could try using pick object by comparison..

    I guess using a for each object would work too

  • Works perfectly now, thanks a lot!

    And here is the final effect. <img src="{SMILIES_PATH}/icon_e_wink.gif" alt=";)" title="Wink">

    http://giphy.com/gifs/game-healers-ques ... 1qhQp5sa4g

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)