Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Stopping a Sprite with velocity

Author
Message
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 30th Jan 2012 16:02
Hello, I'm trying to work out a way of stopping a sprite after velocity has been applied (as if its hit a wall). I have tried many things like applying the same force in the opposite direction, turning off the physics etc, all to no avail... I need to set this sprite as kinematic so cannot simply use SetPhysicsWall (I will have other physic enabled sprites) which the wall cannot be there for...

Does anyone have any suggestions?

Here is what I have at the moment, and if you hold the left arrow key, the sprite 'bounces' off the left edge. What I want is for it to stop dead(as if there is a wall there).



Thank you!!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 30th Jan 2012 16:18
Try this:


I just changed your condition for setting the velocity to zero slightly.

Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 30th Jan 2012 16:41
Genius... Thanks Baxslash, been pondering on that one for hours! Ha...
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 30th Jan 2012 16:42
A pleasure as always

Login to post a reply

Server time is: 2024-11-23 01:34:25
Your offset time is: 2024-11-23 01:34:25