one object triggers another ( neither object the player)
I have an object a child of the player called "crosshair" and tagged as such. the object is in front of the player so when THAT hits the trigger zone( not the player) I want the animation on the game object called and tagged "dancertest" to play. But I can't get it to work and can't understand why. If I substitute "player" in the script like so at at he end...... if(other.tag == "Player") instead of if(other.tag == "crosshair") the player then triggers the animation I want. So what am I missing here? Everything seems to be in order or substituting that one word wouldn't work either. This object called "crosshair" has a box collider on it, name and tag match script
using UnityEngine;
using System.Collections;
public class InAim : MonoBehaviour {
GameObject crosshair;
GameObject dancertest;
Animation animation;
void Start () {
crosshair = GameObject.FindWithTag("crosshair");
dancertest = GameObject.FindWithTag("dancertest");
//animation = GameObject.GetComponent.("dancertest")<Animation>();
}
void OnTriggerEnter (Collider other) {
if(other.tag == "crosshair")
dancertest.GetComponent<Animation>().Play();
}
}
Answer by Thajocoth · May 26, 2016 at 06:38 PM
Which of the colliders involved are and are not triggers?
When I've had both trigger and non-trigger colliders that I want the same object to trigger a response to, I've had to give that object double the colliders... One trigger copy and one non-trigger copy, as the trigger colliders only trigger other trigger colliders and vice versa.
I have no idea if that's your issue or not, but if it is, it should be easy enough to fix.
Your answer

Follow this Question
Related Questions
OnTriggerEnter and Exit using Position Markers? help?? 1 Answer
How do i make my arrow hit an enemy and instantiate a blood sprite in its place? 0 Answers
I want to freeze fp player , animation then starts , then unfreeze the character . 0 Answers
AI Open Door (Collision detect) 0 Answers
How to Instantiate a prefab with radius using OverlapCircleAll ? 0 Answers