Destroy Object after travelling the width of its Parent

0 favourites
  • 3 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hey guys, could someone check my logic - I have no idea why it's not working!

    + System: On start of layout
    -> mobiPath: Spawn deathBullet on layer 0 (image point 1)
    -> deathBullet: Set angle toward (mobiPath.ImagePointX(2), mobiPath.ImagePointY(2))
    ----+ deathBullet: Bullet distance travelled = mobiPath.Width
    -----> deathBullet: Destroy[/code:wbxm5uy9]
    
    I'm trying to make a spawner create an object that will travel the distance of its parent before being destroyed - but the above code doesn't work
    
    Any insights would be greatly appreciated
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I managed to get a workaround with the following:

    + System: On start of layout
    -> mobiPath: Spawn deathBullet on layer 0 (image point 1)
    -> deathBullet: Set angle toward (mobiPath.ImagePointX(2), mobiPath.ImagePointY(2))
    -> deathBullet: Set distance to mobiPath.Width
    
    + deathBullet: Bullet distance travelled = deathBullet.distance
    -> deathBullet: Destroy
    [/code:1dd5rjdu]
    
    I still have no idea why the first example didn't work - in my head they do the same thing
  • The first example didn't work, because On Start of Layout the bullet is not even created yet, and of course hasn't traveled any distance.

    So the way you fixed that was absolutely correct.

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