- Home /
Newbie question about variable
Hello, how do I use variable "target" instead of the name of the object "box1" in this script:
var target : Transform;
function OnTriggerEnter (hit:Collider) {
if(hit.gameObject.name == "box1"){
Comment
Best Answer
Answer by irrationalistic · Aug 27, 2012 at 04:27 PM
The "transform" object has a property called gameObject as well. You would do:
if(hit.gameObject == target.gameObject) {
Your answer
