- Home /
test platform
Hi,
I want to test to see if I have landed on a moving platform (top surface). I have a controller to test on a rigidBody. The only way I can see doing this is to test the normal to see if I hit the top surface.
Is there a better way?
void OnControllerColliderHit(ControllerColliderHit hit) {
//print (ihit.gameObject.name);
if ( hit.gameObject.name=="platformMove")
{
print ("hit moving platform");
Debug.Log("Normal vector we collided at: " + hit.normal);
Debug.Log(hit.moveDirection);
}
} //void
Just add another new, separate collider to the area you are interested in.
(For example, a large flat cube.)
In the very specific situation you describe, you can, very simply, check that the "y value" of your lander is above the platform. But the way to proceed is simply add a "landed-on" collider on that surface!!
Answer by hagar · Jun 18, 2012 at 12:37 PM
I have got it to work like this and it already has a collider and rigibody. Dont know what you mean with another collider.
void OnControllerColliderHit(ControllerColliderHit hit) {
if ( hit.gameObject.name=="platformMove")
{
vec=new Vector3(0,1,0);
if (vec==hit.normal)
{
onPlatform="true";
platform=GameObject.Find("platformMove");
}
else
{
onPlatform="false";
}
}
Your answer
Follow this Question
Related Questions
Spawning animals at a random postion on platforms. 2 Answers
Issue on moving using CharacterController 1 Answer
How to import project? 3 Answers
Flying Platform jump 3 Answers
Collision on the bottom? 1 Answer