- Home /
ball penetration
I have moving platform made by animation and ball,
platform - rigidbody and box collider. ball - rigidbody and sphere collider.
When i run into moving platform the ball penetrate and fall down. How can i make to ball elevate by platform?
Answer by ElGordoGato · Oct 24, 2016 at 05:23 AM
Make sure both rigidbodies are kinetic and the colliders are not triggers. Thats what worked for me.
Don't know why you didn't try what I put. I use it all the time and it does work. Or at least if you did try you didn't say anything.
Answer by N1warhead · Oct 23, 2016 at 10:30 PM
You can try
// All you have to do is make the ball the child of the platform
// Add this to the player
// You might have to do OnCollisionStay
void OnCollisionEnter(Collision col){
if(col.gameObject.tag == "Platform"){
gameObject.transform.parent = col.gameObject.transform;
//Disable any Components below this that you might need to do.
//Comp1
//Comp2
//Etc.
}
}
void OnCollisionExit(){
//De-Parent our ball from the platform
gameObject.transform.parent = null;
//Re-enable any components below this.
}
If this is correct and works for you, please mark this as correct so others will know. Hope that helped.
Your answer
Follow this Question
Related Questions
animation Collider 3 Answers
Unity 4.5.2 bug changing the properties of the 2d colliders in animation 1 Answer
How to jump on to a turret gun 2 Answers
OnTriggerStay instead of input 2 Answers