- Home /
Question by
LaMa2223 · Jan 14, 2021 at 04:40 PM ·
collidersfieldofviewfield of viewif-else
Trigger on collider if another collider is in field of view
I try to trigger a UI on collision with object A, if object B is in sight (of first person player).
The collision with object A already works, but I don't know how to implement the combination of >trigger on collider A< AND >object B in field of view<.
Can anybody help? This is the code I am using so far…
Comment
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class appearUI3 : $$anonymous$$onoBehaviour
{
[SerializeField] private Image customImage;
// Start is called before the first frame update
void Start()
{
customImage.enabled = false;
}
void OnTriggerEnter(Collider other)
{
if(other.CompareTag("Player"))
{
customImage.enabled = true;
}
}
void OnTriggerExit(Collider other)
{
if(other.CompareTag("Player"))
{
customImage.enabled = false;
}
}
// Update is called once per frame
void Update()
{
}
}
Your answer
Follow this Question
Related Questions
Visual area occupied by each object in field of view 0 Answers
Camera FOV lower than 1? 1 Answer
physics.OverlapSphere colliders 1 Answer
Collider priority with onMouseDown() 2 Answers