- Home /
Why is my character not sticking to platform? (Script included)
Hey, having a little trouble with my game. Basically, I have a moving platform inside my game that moves from left to right on a loop. The player can jump on the platform but as soon as they hit the platform, they slide off (do not stick to it). I have tried doing this with OnCollisionEnter and OnTriggerEnter but it doesn't seem to work.
I know this has been asked before but I cannot relate to any of the answers. Can anyone point me in the right direction? I attach this code to the moving platform :
function OnTriggerEnter (other : Collider) {
if(other.gameObject.tag == "Player") {
other.transform.parent = transform;
}
}
function OnTriggerExit (other : Collider) {
if(other.gameObject.tag == "Player") {
other.transform.parent = null;
}
}
Player tag = Player || Platform tag = Platform.
If you need anymore information, I will be here for a while so feel free to ask. I hope you guys can help :D
Answer by Montraydavis · Oct 14, 2012 at 04:10 PM
If I am understanding correctly, your 3D model slides across the floor as if it were Icey grounds or something ?
There are two ways that I know of that you can go about doing this.
You can set the Rigidbody to kinetic. ( Less efficient )
You will need to change the physics material of the rigidbody .
no no, well it's hard to interpret. Basically the character jumps and collides with the platform but the character stays still whilst the platform continues to move, therefore making the player drop. I want the player to become "glued" to the platform so they move with it, until they jump off it which would be OnCollisionExit?
Your answer
Follow this Question
Related Questions
How do I make objects stick to moving platforms? 1 Answer
Moving Platform with multiple targets 0 Answers
Something on a moving platform 2 Answers
Rigidbody on a platform 2 Answers
Multiplayer - Other players shaking back and fourth on moving platform 2 Answers