I need help in an action, that is to say that I have a collision function, what I want to do is that when the player object collides with that object that has the collision method my player turns red by the time that has entered the field of collision and then when it comes out of there it returns to its original color or material, is what I want to do, but I do not know how, I thank help in advance I have this code in collisions:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class colisionvida : MonoBehaviour {
int Dano = 0;
void OnTriggerEnter(Collider otro){
Debug.Log ("Colisiona");
otro.gameObject.SendMessageUpwards ("QuitarVida", Dano, SendMessageOptions.DontRequireReceiver);
}
}
And this in life:
void start(){gameObject.GetComponent().material = materialB;}
void QuitarVida (int Dano) {
Vida -= Dano;
gameObject.GetComponent().material = materialA;
}