i making a platform game and whenever i stop moving my actor slides. How do i make it so that when i done pressing left or right key the actor does not continue to move.
Comments
tenrdrmerMember, Sous Chef, Senior Sous-ChefPosts: 9,934
Depends on the rule your using to move. but You can try adding friction to the actor. If its an accelerate rule I believe you need drag and friction. or you can do an otherwise to you button down rule that sets the velocity back to 0 but that may give too sudden of a stop.
tenrdrmerMember, Sous Chef, Senior Sous-ChefPosts: 9,934
When key right is down --accelerate toward Then in other wise change attribute self.linearvelocity.x to 0
That would give you an abrupt stop. so if you didn't want that you could put in interpolate attribute self.linearvelocity.x to 0 -duration .25 or .5 and then in function do ease in. this will cause the velocity to come back to 0 over what ever time period you set.
But what are you moving does the move behavior not work for you I believe it would actually stop as soon as you let the key up eliminating the need for the otherwise.
Comments
when i out that in did the same thing it did before
--accelerate toward
Then in other wise
change attribute self.linearvelocity.x to 0
That would give you an abrupt stop. so if you didn't want that you could put in
interpolate attribute self.linearvelocity.x to 0
-duration .25 or .5 and then in function do ease in. this will cause the velocity to come back to 0 over what ever time period you set.
But what are you moving does the move behavior not work for you I believe it would actually stop as soon as you let the key up eliminating the need for the otherwise.