Define Collision points in code
by Andre Clark · in Torque X 2D · 09/28/2009 (3:07 am) · 2 replies
Hello everyone, I've been searching through the forums for a possible solution to this, but have not been able to find any help.
So basically throughout my game the player's sceneobject changes size and I need to reposition the collision points so the player doesn't look awkward as it walks on platforms. I want to have the ability to alter the collision points when the sceneobject changes size. I've been able to locate a vector of collision points, but this vector is read-only. Is there a way to get the collision points and change them on the fly?
Any help would be appreciated :)
So basically throughout my game the player's sceneobject changes size and I need to reposition the collision points so the player doesn't look awkward as it walks on platforms. I want to have the ability to alter the collision points when the sceneobject changes size. I've been able to locate a vector of collision points, but this vector is read-only. Is there a way to get the collision points and change them on the fly?
Any help would be appreciated :)
#2
So essentially to change this you will have to obtain the T2DPolyImage you would like to change and change it's CollisionPolyBasis property to the points you desire.
A few things to note when you do this:
- CollisionPolyBasis's vertices are defined within object space.
- You must ensure that CollisionPolyBasis is a convex polygon.
At least this is my understanding when I've gone through and defined some of my own collision detection for Torque.
09/28/2009 (1:47 pm)
Without any changes I am pretty sure Torque takes what is defined in the T2DPolyImage's CollisionPolyBasis property. At the appropriate time a collision needs to be checked then CollisionPoly is generated (via the _GenerateCollisionPoly() method) which is simply the CollisionPolyBasis scaled the the T2DSceneObject's size. Poly-poly collisions are then checked via seperating axis theorem.So essentially to change this you will have to obtain the T2DPolyImage you would like to change and change it's CollisionPolyBasis property to the points you desire.
A few things to note when you do this:
- CollisionPolyBasis's vertices are defined within object space.
- You must ensure that CollisionPolyBasis is a convex polygon.
At least this is my understanding when I've gone through and defined some of my own collision detection for Torque.
Torque Owner Sean Monahan
I'm off to work right now but I can take a closer look this evening.