- Home /
I want to make the gameobject rigidbody.iskinematic=true for 3s and immune to damage when it triggers the collider and then false again
public class Personaje : MonoBehaviour {
public float speed = 2;
public int vidaMaxima;
private int vidaActual;
private Rigidbody rigidBody;
// Use this for initialization
void Start()
{
rigidBody = GetComponent<Rigidbody>();
rigidBody.freezeRotation = true;
vidaActual = vidaMaxima;
}
// Update is called once per frame
void Update ()
{
transform.position += Vector3.forward * speed * Time.deltaTime;
}
public void RestarVida()
{
vidaActual--;
}
public void OnTriggerEnter(Collider other)
{
if(other.tag == "Enemy")
{
//GetComponent<Rigidbody>().isKinematic = true;
RestarVida();
Debug.Log("Restar vida");
}
}
}
Comment
Your answer
Follow this Question
Related Questions
My player's camera displays jerky objects 2 Answers
Strange issue with collider 1 Answer
How to move Groups of Objects using a Script? 0 Answers
OnTriggerEnter does not work 1 Answer