Hi, i want that when my player looks at an object and presses E, it shall dissapear, i have literally no idea how to do this so could you please help?
There’s no need for raycasts and colliders - when you press E simply take the dot product of the facing vector with the vector from the player to the target.
Vector3 dir = (target.transform.position - transform.position).normalized; float dot = Vector3.Dot(dir, transform.forward);
If dot is 1, the player is looking exactly at the target. If it’s -1, they’re looking completely away from it. Set your own limit to test against how accurate you want them to be to be considered as looking at the target (e.g. >0.9, say)
Thank you, idk how raycast works and how to implement it, could you maybe help me more, or else i will just google.