I’m aiming to create a camera movement limitador on the borders of my scenario, don’t know if there’s a better way to achieve this, but I was thinking about using triggers and a raycast to detect the position of the mouse on the borders, once the raycast hits the trigger, the camera movement must stop. It happens that raycast is not detecting the collision with these triggers. Not sure if this is happening because of these triggers are above of the plane (with mesh collider) that I’m using as scenario.
After some googling, I found some answers about raycasts and triggers, then the collider’s property “isTrigger” was mentioned, but it’s not working either. My code is something like this:
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit;
if(Physics.Raycast(ray, out hit))
{
if(hit.collider.isTrigger)
{
//When the mouse is hovering the trigger this isn't being called
}