when my player get’s hit by the enemy. the player stand’s still i want it to be were if the player get’s hit by the enemy the player will fall to the ground and rotate or go falling in the air think of it as if he was getting hit by a car. the player is using a Character Controller and a Rigidbody (Is Kinematic is on) the enemy has only a Rigidbody
Player Script
public float jumpSpeed = 0.7f;
public float gravity = 2;
CharacterController controller;
Vector3 currentMovement;
// Use this for initialization
void Start ()
{
controller = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update ()
{
if (!controller.isGrounded)
currentMovement -= new Vector3 (0, gravity * Time.deltaTime, 0);
else
currentMovement.y = -9.81f;
if (controller.isGrounded && Input.GetButtonDown("Jump"))
currentMovement.y = jumpSpeed;
controller.Move (currentMovement);
}
}
Enemy Script
public float speed;
void Start ()
{
}
void FixedUpdate ()
{
rigidbody.velocity = transform.forward * speed;
}
}