Hi! I wanted to make it so when the player clicks in my game it launches a raycast from the cameras front going away from the camera, but I don’t know how I would do that. Currently, I have it so it raycasts to the mouses click position, but if the mouse isn’t centered with the screen it doesn’t work correctly. Can anyone help?
I currently have a bad solution, which consists of placing an entity far away from the camera, but I want to change it.
Hey @Cryptonaph,
You might want to take a look into the pc.app.systems.rigidbody.raycastFirst(from, to)
, which returns the result of the raycast, including the position where the raycast intersected.
There is a tutorial project and a user manual page that showcases this in action, allowing you to mouse over entities and click them.