Stumped in this one. I have a gameobject ( a crane) that animates by rotating as well as its arm going up and down. This is activated by the arrow keys. What I am trying to accomplish is that if , while the crane is rotating, the arm of the crane hits an obstacle ( like an " I" beam) that the turret can not rotate in that direction any more ( forcing you to raise the arm to clear the obstacle) . I have tried putting colliders and triggers on just about everything, setting the animation speed to zero, triggerenter, collider enter etc. I can’t put a collider on the component with the animation component because that isn’t what collides. I have to put a collider on the joint below that so it will move like the arm does. I think it has to do with the collider on the crane being a child of the part with the actual animation component? So here is the script…while rotating left, if the arm hits an obstacle it turns off the script that enables the turret to rotate that way, if you rotate the other way ( triggerexit) the script goes back on. I have tried CollisionEnter and just about everything I can think of. Please help with ANY advice or comments
using UnityEngine;
using System.Collections;
public class blockCraneRotate : MonoBehaviour {
private MonoBehaviour rotate;
GameObject crane;
GameObject Ibeam;
void Start () {
crane = GameObject.Find("CraneTest");
Ibeam = GameObject.FindWithTag("blockcrane");
rotate = GameObject.Find("CraneTest").GetComponent<CraneLeft>();
}
void OnTriggerEnter(Collider other) {
if(other.tag == "blockcrane")
{
rotate.enabled = false;
}
}
void OnTriggerExit(Collider other) {
if(other.tag == "blockcrane")
{
rotate.enabled = true;
}
}
}