- Home /
Other
I want my Player to have collision physics
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;
}
}
I'm slightly confused as to what you're asking. Are you saying you want your player to be detected as a trigger AND react to physics (so nothing passes through it)?
CC and rigidbody together is not a good idea. They don't play well together.
Answer by EggQuiz857 · Feb 24, 2015 at 11:55 PM
add colliders around the player and add a rigid body to it and it should work like insert a sphere collider.