I need a way to initiate a raycast from the camera when the player uses the mouse. Kind of like a laser, only once per click. I was trying to get together a method using rigidbodies, but the collision was faulty, and it was too slow.
Answer by DaveA
Feb 23, 2011 at 02:40 AM
Take a look here: http://unity3d.com/support/documentation/ScriptReference/Camera.ScreenPointToRay.html
Code there sounds like what you need
Thanks, I got it working. No console errors.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
To help users post good questions and use the site effectively we have posted a user guide. Please check it out.
Answers and Comments
No one has followed this question yet.
Ray Cast not working for camera.
Raycast collision on camera see's only part of object
Raycast from one camera using a gameobject relative to another camera
Null reference exception on Screenpointtoray (Multiplayer)
How to Lerp and Clamp