- Home /
A Part of a Script Stops working when another object is not active.
A part of a gun script that rotates the gun around the player, stops working when a object that I'm not referencing in any way from the gun script.
In the gun script, everything works fine, until I disable that object. Then the gun stops rotating around the player, but it's able to shoot.
And, in the other object's script, or in any other, I don't disable any part of the gun script if the object is not active.
The object is something like a Building Cursor, and I want the player to be able to shoot just when the cursor is not active. But when that didn't work, I just replaced it for a backup, and it's still not working.
This is the part of the code that stops working. No if's.
Vector3 orbVector = Camera.main.WorldToScreenPoint(orb.position);
orbVector = Input.mousePosition - orbVector;
float angle = Mathf.Atan2(orbVector.y, orbVector.x) * Mathf.Rad2Deg;
pivot.position = orb.position;
pivot.rotation = Quaternion.AngleAxis(angle - 90, Vector3.forward);
Thank you in advance.
And, none of the objects referenced in that code get disabled at any time.
Your answer
![](https://koobas.hobune.stream/wayback/20220612235359im_/https://answers.unity.com/themes/thub/images/avi.jpg)