![]() Notice that I’ve multiplied the direction value by 10. Like this: Debug.DrawRay(ray.origin, ray.direction * 10) Like this: Ray ray = new Ray(transform.position, transform.forward) Īnd then, render a visible line using Draw Ray, passing in the same values as I used to create my Ray. This function can be useful for making sure your Ray is going where you want it to.įor example, I could define a Ray variable for use in Raycast functions. Like this: Debug.DrawRay(Vector3 origin, Vector3 direction) ![]() The Debug Class includes a function, Draw Ray, that allows you to render a Ray in the world. ![]() Using Debug.DrawRay, you can check if your Rays are going where they’re meant to.ĭid you know you can visualise Rays in the game world? Otherwise, when you come to use the Ray, it won’t be in the right position. Ray = transform.position, transform.forward So, for example, if your Ray’s origin and direction are going to be different every frame, you’ll need to update the Ray every frame too. However, while you can cache a reference to the Ray you create, you’ll still need to update it every time you use it. These helper functions make it easy to create a Ray from an existing point in the world.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |