How do I have an object return to it's original height?

0 favourites
  • 5 posts
From the Asset Store
It's here!
$4.95 USD
Creepy and nasty horror track. It's terrifying from the beginning till the end. Goosebumps guaranteed
  • I want an object to dive down, hit something, then return to it's original height before doing it again.

    I was originally having it do this by drawing a long thing sprite when it started diving and then having it colide with that off a bounce, but that was making it get lower and lower with each subequent dive because of the thickness of the sprite.

    So now I'm trying this with having a variable set itself at the objects y position when it starts the dive, and then checking when it hits a y postion equal to the variable to stop it, but it's not doing anything and I'm not sure why?

  • Probably because the Y co-ord can be to many decimal places so it's struggling to get an exact match. Try using floor(sprite.y) to round to a whole number or use the good old less than or equal to sprite.Y.

  • If you're using Set Size, then this is likely due to the way relative scaling works in C2 (and I guess C3). The most direct way is to store your height in an instance variable, which is initialised at layout load. That way you always have a value reference with which you can use 'Set Scale' which is more reliable.

  • I think by "height" he meant "distance" - after bouncing off solids the object should travel the same distance back.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Less than or equal too worked perfectly, cheers Plinkie.

    Yeah sorry faulknermano I wasn't clear enough, by height I meant it's y position on the map, not the height of the actual object.

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