- Home /
Unity c# Raycast axis stuck on one axis
I DID use transform.forward instead of a Vector3.forward, and whilst it is rotating fine on the x axis, whenever I aim up and down it won't rotate on that axis, it just sort of "slides" up and down with the barrel gameObject it is referencing.
public GameObject barrel;
void Update ()
{
weaponSystem();
}
void weaponSystem()
{
//Weapon System for GUN
//------------------------------
Debug.DrawRay(barrel.transform.position, transform.forward * weaponRange);
Ray gunRay = new Ray(barrel.transform.position,transform.forward * weaponRange);
}
Comment
Never$$anonymous$$d, I figured it out. In the transform.forward I forgot to reference the barrel gameObject. So simple! I want to leave it up incase anyone else has that issue ;)
Your answer
Follow this Question
Related Questions
How to change a mesh using a script? 1 Answer
Gun locator script isnt working 1 Answer
Raycast Targeting issue 1 Answer
How can i make a ray cast take health from enemies 2 Answers
Raycast Projectile w/ Physics 2 Answers