Physics Behaviour

0 favourites
  • 12 posts
From the Asset Store
Simple yet very life-like rag doll made with Physics!
  • Dear All,

    I am just stuck in achieving a simple thing, and desperately looking for help.

    Well i have a sprite and have applied physics to it. Well its a ball and it fires at the angle where the mouse is pointed on mouse click.

    Now what i want to achieve is, when the ball(which has physics behaviour applied) and i move it using impulse towards angle,

    well i want when the ball stops moving i want the game to over and apply like try again or anything, but i cant get the coding sorted what needs to be done.

  • Try this:


    System -> Sprite.Physics.VelocityX = 0


    System -> Sprite.Physics.VelocityY = 0


    End Of Game

  • ok Dear RangerJim, this sounds understandable, but the thing is on start of layout the ball is already static, and moves only on mouse click, so when then game will start, the velocity 0 condition will match and it it will end the game on start of layout.....

  • you could check to see if the object Is sleeping (physics property)

  • Make a new variable. If the velocity goes above 0, set this variable to 1. If the new variable is 1 and the velocity is 0, you know it has moved and stopped.

  • spongehammer, again i tried that, but as i have mentioned, the object on start of layout is already static/sleeping and only moves on mouse click... so it doesnt helps...

    i have also tried to make 2 conditions meet like if physics is sleeping and object is overlapping the base/ground even then it doesnt works....

  • Nimtrix's solution is what I was going to write after I read the first post, but obviously he got there first ;)

  • Nimtrix and Procrastinator i already tried that, it doesnt work either...

  • Ah ok then it must be to do with real numbers. Physics velocity could be at 0.01, which is still > 0 , so it won't stop.

    Try what Nimtrix suggested, but..

    If floor(velocity) > 0 then hasStopped = false


    hasStopped = true

  • procrastinator dude didnt work out... with the nimtrix suggestion... and ur last suggestion i couldnt quite make sense of it... am still a kid with this software...

  • Have a condition such as a boolean called touched. So you can say if not sleeping, set touched to true. Then you can have 2 conditions that say if touched is true and object is sleeping, game over. That make sense? <img src="smileys/smiley4.gif" border="0" align="middle" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • AnD4D thanks for the reply... ill try and will let you know...

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