-1

I want to know how I should rotate my Raycast start point (Raycast direction) when I want to get an object in front of the Object from the player's perspective.

This is how I like to use it.

startTransform.eulerAngles = ???;
if (Physics.Raycast(startTransform.position, startTransform.TransformDirection(Vector3.forward), out hit, Mathf.Infinity, _layerMask))
{
        Debug.DrawRay(startTransform.position, startTransform.TransformDirection(Vector3.forward) * hit.distance, Color.yellow);
}

Thanks for your help

Fabian
  • 71
  • 2
  • 10

1 Answers1

0

I only had to find out the direction. Vector3 direction = startTransform.position - playerPosition;

Fabian
  • 71
  • 2
  • 10