OnTriggerEnter only if two tags are found?

Hi there.

I have a script attached to my camera that enables me to rotate it around my Player when pressing either z or x.
However, I need the keys only to be enabled when the player enters a certain collider tag (called rotateZone atm.).

I’ve searched and tried several solutions, but the OnTriggerEnter wont trigger for me. I guess the issue is that the camera never enters the trigger, only the player does. But the camera is attached to the player object, so this ought to not be the problem.

So the question is:

In my CameraRotator script, with the use of OnTriggerEnter/Exit, how do I check if a gameobject with the tag “Player” has entered the trigger/collider of a gameobject with the tag “rotateZone”? Should I use FindGameObjectsWithTag?

Here’s the script attached to the camera. I’ve removed the current tag and collider solutions I’ve been using, since they aren’t working.

Any help would be appreciated :slight_smile:

CameraRotator

using UnityEngine;
using System.Collections;

public class CameraRotator : MonoBehaviour 
{
	public float rotateTime = 1.0f;
	
	private bool _isTweening = false;
	private CrunchPlatformColliders _cruncher;
	private DisablePlayer _disablePlayer;
	
	void Start () 
	{
		_cruncher = GetComponentInChildren<CrunchPlatformColliders>();
		GameObject player = GameObject.FindGameObjectWithTag("Player");
		_disablePlayer = player.GetComponentInChildren<DisablePlayer>();
	}
	
	void Update () 
	{
		
		if (Input.GetKeyDown(KeyCode.Z))
		{
			rotateTween(90);
		}
		
		if (Input.GetKeyDown(KeyCode.X))
		{
			rotateTween(-90);
		}
	
	}
	
	private void rotateTween(float amount) 
	{
		if (_isTweening == false) 
		{
			_isTweening = true;
//			_cruncher.setPlayerPos();
			_disablePlayer.disable();
			Vector3 rot = new Vector3(0,amount, 0);
			iTween.RotateAdd(gameObject, iTween.Hash(iT.RotateAdd.time, rotateTime, iT.RotateAdd.amount, rot, iT.RotateAdd.easetype, iTween.EaseType.easeInOutSine, iT.RotateAdd.oncomplete, "onColorTweenComplete"));
		}
	}
	
	private void onColorTweenComplete()
	{
		_isTweening = false;
		_disablePlayer.enable();
		_cruncher = GetComponentInChildren<CrunchPlatformColliders>();
		_cruncher.crunchCollidersToPlayer();
	}
}

On the gameobject rotateZone add this to script

   OnTriggerEnter (Collider other) {
    if (other.tag == "Player") {
    // do stuff
    }
    }