- Home /
Character Controller falls through moving/rotating platforms (Not A Duplicate Post)
So I've spent all day on this and am just getting discouraged. I started on moving platforms (left right up down) and was falling through those. I fixed it using runevision's answer here http://answers.unity3d.com/questions/8207/charactercontroller-falls-through-or-slips-off-mov.html
Then I found that if the player jumps towards a platform that is moving towards the player, the player jumps right through the platform. I fixed that by shooting a raycast up and if it hits a moving platform, I change the y direction of the player. It works but now I have a ray cast every frame checking something that only happens every once in a while.
Now I have rotating platforms that the player falls through a ridiculous amount of times. I've tried a bunch of combinations of colliders and rigidbodies with colliders inside of bigger colliders inside of bigger colliders but nothing stops it from just passing through. Rotating it with transform.Rotate
and rigidbody.MoveRotation
It might be hard to understand so I uploaded a video of it http://youtu.be/jJ5GAs9CGqQ
The thickness of the platforms also doesn't matter. Moving platforms are sort of a big part of my game and I don't know what to do if collisions aren't working. Does anyone have any suggestions?
I have a ray cast every frame checking something that only happens every once in a while.
Fire it on jump?
transform.Rotate
Use AddTorque
Perhaps change player collision detection to Continuous.
Not a duplicate post but its is a 'duplicate question'; a frequently asked question :)
Fire it on jump?
Thanks, I'm so burnt out on this, I didn't even think of that.
Your other suggestions have been tried and still have the same results
Answer by Sborra · Jun 21, 2014 at 12:54 PM
What i did is that i put a tag called platform in all the platforms, then i detected when the character controller is in touch with the box collider and then i parent the character to the platform, so it stays with the platform and doesn't fall through.This worked for me like this in JavaScript:
function OnTriggerStay(other:Collider){
if(other.gameObject.tag == "platform"){
transform.parent = other.transform;
}
}
function OnTriggerExit(other:Collider){
if(other.gameObject.tag == "platform"){
transform.parent = null;
}
}
CS:
void OnTriggerStay(other:Collider){
if(other.gameObject.tag == "platform"){
transform.parent = other.transform;
}
}
void OnTriggerExit(other:Collider){
if(other.gameObject.tag == "platform"){
transform.parent = null;
}
}
Your answer
Follow this Question
Related Questions
Rigidbody doesn't rotate after collision 3 Answers
Odd collider rotation 1 Answer
Get angle from impact 2 Answers
Rigidbody colliders 1 Answer