- Home /
How does rycast work?
Hi, I have been making something like minecraft clone. Not to play or anything, just a challenge to myself. I wont even release it. Purly for education pruposses. I have some things set up but how do I break / place blocks? I did some research on dynamic creating of gameobjct and found Raycast. The docummentation is poor thought and I didnt find any suiting tutorials. Can anyone explain or point me to explenation (not just the methods that are to it but what it does, I dont think I understand it propereally) (I want to know as much as I can, so I guess simple answer wont be enaught :D).
Answer by dsada · Jun 07, 2014 at 03:25 PM
http://unity3d.com/learn/tutorials/modules/beginner/physics/raycasting
I cant beleive that anyone can make better description than this
Answer by Jeff-Kesselman · Jun 07, 2014 at 03:14 PM
Raycast has nothing to do with creating dynamic objects. Ray cast is a collision function used for pick rays and such.
TO dynamically create an object in Unity you need to
Create a mesh
Create a game object
Assign the mesh to the game object
Assign a renderer to the game object
If you want it to react to physics you also need to assign a rigidbody and a collider to the game object
I wanted to check with the raycast to know where to create the game object. thanks thought
Then you probably want
http://docs.unity3d.com/ScriptReference/Camera.ScreenPointToRay.html
as in Camera.main.ScreenPointToRay(...)