Hi! it’s my first time with the unity Answers and as you will see, I’m kinda new to unity itself. I’m at the learning process of understanding the basic of this great software.
So, as my first question, is there a way to change the color of a simple cube when the player collide with it, using the javascript?
I understand the principle of collision and the tag, I just need to know the “Script” err… command?
var otherTag : String ; //assign in inspector the tag of the cube
// make sure you tag your cube also
var otherColor : Color ; //pick a color in the inspector to change the cube to
@HideInInspector
var controller : CharacterController ;
function Start(){
controller = GetComponent(CharacterController) ;
}
function OnControllerColliderHit(other : ControllerColliderHit){
if(other.gameObject.CompareTag(otherTag)){
other.gameObject.renderer.material.color = otherColor ;
}
}