- Home /
Rigidbody move Character Controller
So I want to be able to have "certain" rigidbodies that collide with my charactercontroller to cause the character controller to move. I know that it kind of...defeats the purpose of using a character controller in the first place, but I would really just like to add some code on top of that to make it work, as opposed to making an entire rigidbody based charactercontroller. Thanks
Usually I get a lot of answers to my questions from this community, but as of late no one has been answering my questions :-. Is it because they're stupid questions lol?
Answer by karthik · Jul 27, 2010 at 06:37 AM
Apply rigid body to your character and add this code for the object which is going to destroy and make effects for character.
//Apply a Player Transform to choose the character transform.
if (Vector3.Distance(player.transform.position, transform.position) < 15) { // Make player die HealthController hc = player.GetComponent(); hc.health = 0;
// Make player fly into the air
CharacterController cc = player.GetComponent<CharacterController>();
cc.Move(((player.transform.position - transform.position).normalized * 15 + Vector3.up * 5) * Time.deltaTime);
}
Your answer
Follow this Question
Related Questions
Simple Tank Controller 2 Answers
Step Offset for Rigidbody Character 1 Answer
Character - Collider With Scene 0 Answers
Should a Character Controller attach with Rigidbody? 2 Answers
Character Controller Jittering 0 Answers