Player stutters left and right when running against wall
by Greg C · in Torque Game Builder · 10/06/2013 (7:46 am) · 4 replies
I am using the common platformer movement script found in the ninja platformer tut and I find that when my player runs into a wall, if I keep attempting to move against it, instead of just stopping the player, he jitters and stutters against the wall, almost bouncing on/off it really fast.
Is there anything I can do to have the sprite just stop when it reaches the wall of the tilemap blocks?
T2D 1.8 - TGB 1.7.6
Is there anything I can do to have the sprite just stop when it reaches the wall of the tilemap blocks?
T2D 1.8 - TGB 1.7.6
#2
10/06/2013 (9:27 am)
He is bouncing off of it really fast - your input is telling the sprite to add velocity in that direction, then it collides with the wall and bounces back. Off the top of my head, if you place a trigger at each point that you can run into a wall you can use onEnter and onLeave trigger to disable/enable movement in the direction of the wall - this would prevent that behavior, but it isn't a very good solution.
#3
10/06/2013 (10:35 am)
I have set the "Collision Response" property of both the player and the tilemap blocks to "Clamp". I would expect it to clamp, not bounce. The player doesn't bounce around on the floor, only the walls. I was sort of approaching something similar to what you mention, but just through some additional collision code, but I figured I would post here first before I attempted to handle it myself as it seems like something that would just work.
#4
I also had issues with this method when attempting to use triggers, which I am going to post about in my other active thread.
10/08/2013 (5:13 pm)
I ended up using the same method that is used to find if the floor is about to be beneath you, with castCollision(), but across the x axis instead of the y. Seemed to work ok, but i think that when I pushed the values to where the player didn't bounce any more, that it pushed them out from the wall a bit. The player is not real close to the wall, they would have been closer given the player just clamped to a wall.I also had issues with this method when attempting to use triggers, which I am going to post about in my other active thread.
Torque Owner Greg C