Question by
toonspanenburg · Jan 29, 2018 at 07:52 AM ·
2d gameguns
I wanted to make a gun script for my 2d game, but aparently there is something wrong with my freezerotation
//The rest of the script seems to work only the freezerotation seems wrong
void Start () { if (rigidbody) rigidbody.freezeRotation = true; originalRotation = transform.localRotation; Vector3 worldMousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector2 direction = (Vector2)((worldMousePos - transform.position)); direction.Normalize(); // Creates the bullet locally GameObject bullet = (GameObject)Instantiate( bullet1, transform.position + (Vector3)(direction 0.5f), Quaternion.identity); //Adds velocity to the bullet bullet.GetComponent().velocity = direction bulletVelocity; }
Comment