Hey Guys,
I’m having a little trouble with my Top Down 2D game. I would like my player to shoot a RayCast2D in the direction he is facing, but creating the directional vector is causing an issue. The Ray does not shoot in the correct direction. Here is my script:
Transform firePoint;
void Awake()
{
firePoint = transform.Find("FirePoint");
}
void Update()
{
Quaternion rotation = PlayerController.playerRotation;
Vector3 direction = rotation * Vector3.forward;
RaycastHit2D hit = Physics2D.Raycast(firePoint.position, direction, 100);
Debug.DrawLine(firePoint.position, direction);
}
The vector “direction” is always in a funny place and not in front of my player as it should be.
Any help is appreciated.