- Home /
Falling through Platform
Hello I am pretty new to coding and I have a problem so far. I made a platform and when I step on it I want the platform to destroy itself after 2 seconds.
On the platform I have a box collider with ontrigger checked and this script attached.
#pragma strict
function OnTriggerEnter (other : Collider)
{
if(other.tag == "Player")
{
Destroy(gameObject, 2);
}
}
Now when my player collides with the object, the platform is destroyed but the player falls through the platform its like the player isn't colliding with the object.
Thank You
Answer by IT_Criminal · Jan 15, 2014 at 05:15 PM
Uncheck IsTrigger on the collider and use OnCollisonEnter instead ... or use an extra box collider .... also ... learn to use the documentation ...
I tried both ways but it doesn't work. Now, I dont fall through the platform but the platform doesn't get destroyed. By the way, I use the fps controller from the standard assets. Any ideas?
It does not get destroyed probably because you haven't changed the script properly.
If you use IsTrigger, your player won't collide with the platform and won't stay on the platform, cuz the Trigger does not collide as rigid body. It just record the collision between 2 objects. You have to turn off the IsTrigger. Then change your script to:
function OnCollisionEnter (other : Collider)
{
if (other.gameObject.tag == "Player")
{
Destroy(gameObject, 2);
}
}
Your answer
Follow this Question
Related Questions
Platform Falling when player collides 0 Answers
How do I have my first person travel along with a moving object? 1 Answer
Moving Platform and CharacterController.Move not working. The player falls 3 Answers
Player falls through fast moving platform 1 Answer
How to keep Platform when using BuildPipeline.BuildPlayer 0 Answers