Raycast is constrained to the horizontal axis


The transform.forward is contained to the horizontal axis. it doesn’t rotate vertically making my weapon shoot horizontally even when my weapon is pointing upwards. any ideas as to why this is happening? thanks!

Here’s my code:

if (Physics.Raycast (arv2.transform.position,
				arv2.transform.forward, out hit_var, wep_range) &&
				Time.time >= time_to_fire) {

				Debug.DrawRay (arv2.transform.position,

				time_to_fire = Time.time + 1f / fire_rate;
				shooting = true;

				Debug.Log ("arv2 hit");


The problem had to do with my Timestep. My Timestep was set to 0.002, I switched it back to default 0.02 and the problem went away.

Go to:

edit - project settings - Time

  • Now edit the Timestep

Hello @Fibonacci_0_1_1,

The reason that is the case is because you are using transform. forward, meaning the raycast is restricted horizontally.

When looking up, is the arv2 also rotated?