I am trying to continuously cast few rays from a character at 45 degrees, so I can check the immediate surroundings.
I have this in my Update function:
RaycastHit hit;
Vector3 sensorStartPos = transform.position;
sensorStartPos.y += 0.05f;
Quaternion spreadAngle = Quaternion.Euler(0, -45, 0);
Vector3 newVector = spreadAngle * transform.forward;
Debug.DrawRay(sensorStartPos, newVector);
When the character is spawned, the ray appears to have the correct angle, but when I rotate the character, the ray does not correctly spins with the character:
Demo Screen capture - bf751473d253fc3ac13a5377bf0417f7 - Gyazo
What am I doing wrong?