Collision Boundry
by Trent · in Torque Game Builder · 11/21/2006 (2:24 am) · 5 replies
I have an object (a rectangle) that I want my player to collide with, and I have it working. However, this is a maze game, and I need to know what side of the object the player collides with.
Presently I have to stop the player moving in both X and Y, but I only want to stop the direction of movement that is acually preventing them from moving.
Is that even possible? If not, can I get which segment of the polygon it collided with?
Presently I have to stop the player moving in both X and Y, but I only want to stop the direction of movement that is acually preventing them from moving.
Is that even possible? If not, can I get which segment of the polygon it collided with?
About the author
#2
That's probably a bad description of what is happening. CLAMP is doing its job just fine, its just once you're free from the object... There is only a key down and key up event that I'm aware of, I think I need to be able to poll a key to see if its down each frame.
11/22/2006 (1:47 am)
Yeah I have CLAMP working, maybe its my keyboard handling routine. Basically once you set the LinearY to 0, if the player then goes left while still holding the forward key down, when you get to the edge of the object, you will not go forward, because there is nothing to set the velocity back up.That's probably a bad description of what is happening. CLAMP is doing its job just fine, its just once you're free from the object... There is only a key down and key up event that I'm aware of, I think I need to be able to poll a key to see if its down each frame.
#3
11/22/2006 (3:20 pm)
TGB will send you a key up and a key down event on each key press. So you can just consider a key to be down until you receive a key up event, rather than needing to poll.
#4
Thanks!
11/22/2006 (7:11 pm)
Heeeeeyyyy.......... ok I didn't even think about that possibility... Thanks!
#5
Imagine this:
I press both left and up. I hit the bottom wall. I get a collision event, the normal is (0, -1), so I setLinearVelocityY(0). I slide left along the wall, but I get no more collision events. I don't get a key up event. How do I reset the linear velocity without pressing or releasing another key, or colliding into another wall?
12/01/2006 (2:59 am)
Ok, the problem I am running into now is when I collide, thats it.Imagine this:
I press both left and up. I hit the bottom wall. I get a collision event, the normal is (0, -1), so I setLinearVelocityY(0). I slide left along the wall, but I get no more collision events. I don't get a key up event. How do I reset the linear velocity without pressing or releasing another key, or colliding into another wall?
Torque Owner Thomas Buscaglia