reference camera child
trying to reference the child of a the camera. Yes! read everything here and there. Tons of suggestions. all different, none worked. The name and tag of the object is called "crosshair". The script works if I parent crosshair to the player . Crosshair is a long collider sticking out from the center of the camera aim so that when crosshair collides with the trigger object with this script it enables another script
below is part of my messed up code, can't even bother to clean it up the 300 variations of it didn';t work either
using UnityEngine;
using System.Collections;
public class dancerenabled : MonoBehaviour {
private GameObject dancertest;
private MonoBehaviour AniOn;
GameObject crosshair;
Camera ParentObject;
//public Transform crosshair;
void Start () {
crosshair = ParentObject.transform.GetChild(1);
AniOn = GameObject.Find("dancertest").GetComponent<MonoBehaviour>();
crosshair = GameObject.Find("crosshair");
}
void OnTriggerEnter (Collider other) {
if(other.name == "crosshair")
{
AniOn.enabled = true;
}
}
void OnTriggerExit (Collider other) {
if(other.name == "crosshair")
AniOn.enabled = false;
}
}
Your answer
Follow this Question
Related Questions
Setting localposition to a vector 3 sets everything but the x 1 Answer
Collisions are getting ignored in child objects 0 Answers
[emergency]Know collision between child object of two object 1 Answer
Gameobject transform not moving when doing animation 0 Answers
Instantiated child object position slightly off. Any ideas? 0 Answers