I'm working on a game that looks like an old submarine radar. There is the scanner that goes around the dial and when it hits an enemy, they become visible for a brief moment. Unfortunately, I can't get the OnTriggerEnter2D to work when I attach this script to the enemy.
var fadeSpeed:float=5;
function Update(){
if(gameObject.renderer.material.color.a>0)
gameObject.renderer.material.color.a-=fadeSpeed*Time.deltaTime;
}
function OnCollisionEnter2D(coll: Collision2D) {
if (coll.gameObject.tag == "Scanner"){
gameObject.renderer.material.color.a=100;
transform.position.x=100;
}
}
↧