- Home /
Make Character Fall
Hello Unity3D.I have a question about making objects fall.Which way is the easiest way to make a character fall when hit collides with another character?For example.When my player attacks the enemy i want the enemy to go 10 feet up into the sky and then fall down on to the ground.I have been looking for tutorials but none of them have worked out?If anyone knows an easy way of doing it.Can you please tell me how?
Add an upwads force to the rigidbody using rigidbody.addForce (). Just change the amount of force until it reaches 10 feet high.
Answer by skylem · Jan 13, 2015 at 04:40 AM
U can use a Rigidybody
rigidbody.AddForce(Vector3.up * 10) // or
this will send him up and if useGravity is checked on the rigidybody it will handle the falling alternatively if ur using a character controller
void OnCollisionEnter(Collision Other) {
// this line if u want to see if the character is on the ground
// otherwise false or don't use it at all
if(Other.GetComponent<CharacterController>().isGrounded == true) {
// then the Y position of the transform gets a +
transform.position = new Vector3(0,transform.position.y+10 ,0);
}
}
Answer by sarthakshah · Jan 13, 2015 at 04:31 AM
just give rigidbody to enemy character with enable gravity, and when player attacks the enemy, just give force to the enemy in up direction, and bcoz of gravity it will fall down on the ground itself.
Your answer
![](https://koobas.hobune.stream/wayback/20220613180240im_/https://answers.unity.com/themes/thub/images/avi.jpg)