how would i go about looking at the ‘other’ in OnTriggerEnter??? the two are in different gameobjects so the OnTriggerEnter is on one gameobject, but i want to send the trigger/object that collided to another object that then looks at that target, but for the life of me cant figure it out here is my current set up…
attackRTriggereStay.JS
@HideInInspector
var targetAquired = false;
var attackTarget;
function OnTriggerEnter (other : Collider) {
print(other);
print(targetAquired);
if(other.gameObject.CompareTag ("enemy")){
attackTarget = other;
targetAquired = true;
print(attackTarget);
print("targetAquired");
}
}
function OnTriggerExit (other : Collider) {
if(other.gameObject.CompareTag ("enemy")){
targetAquired = false;
print(attackTarget);
print(targetAquired);
}
}
LookAt.JS
var getTrigger : attackRTriggerStay;
var getTarget : attackRTriggerStay;
function Start(){
getTrigger = GetComponent(attackRTriggerStay);
}
function Update () {
getTarget =gameObject.GetComponent(attackRTriggerStay);
if(getTrigger.targetAquired == true){
transform.LookAt(getTarget.other);
}
}
Was it you who I told that you can merge getTrigger and getTarget into one variable? If you don't understand this you should read something about OOP! Two variables referring to the exact same component, so you can leave out one.
– anon46022118yeah i think it was, but i was thinking it wasn't working so a thought that crossed my mind was that you cant send an objects transform stuff and a boolean from the same one.... dont know why i thought that, but i have been trying to get this thing to work for a while now.....
– IMTRIGGERHAPPY9