- Home /
Question by
rodrigosimpsondebem · Apr 14, 2020 at 02:31 PM ·
raycastvisual studio
Change Raycasr origin
Hi guys
I'm using a Raycast to detect if there's a tile below the NPC. It's a tactical RPG 3D game.
However, there's a problem with the origin of the raycast, because it doesn't detect the tile, even if the NPC is on it, as you can see in the picture
I'm using this code to create the raycast:
public void DetectGround()
{
float rayRange = 10f;
rayDown.origin = transform.position + (-transform.up);
rayDown.direction = -transform.up;
float duration = 15f;
Vector3 Direction = transform.TransformDirection(-Vector3.up) * 10;
Debug.DrawRay(rayDown.origin, Direction, Color.red, duration);
if(Physics.Raycast(rayDown, out hitDown))
{
Debug.Log(hitDown.transform.tag);
}
}
How could I change its origin to start a little further up?
capture.jpg
(25.5 kB)
Comment