private void UpdateShotAngle() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Vector3 temp3 = ray.origin - gameObject.transform.position; FVector2 temp2 = new FVector2(temp3.x, temp3.y); temp2.Normalize(); foreach(Weapon weap in weaponList) { weap.SetDirection(temp2); } }
public void SetDirection(FVector2 newDir) { newDir.Normalize(); direction = new FVector2(newDir.X, newDir.Y); float zAngle = Mathf.Acos(newDir.X)*180.0f/Mathf.PI; if(newDir.Y < 0.0f) { zAngle = 360.0f - zAngle; } zAngle -= 90.0f; //Up is our 0 degrees here :P gameObject.transform.rotation = Quaternion.identity; gameObject.transform.Rotate( new Vector3(0.0f, 0.0f,zAngle)); }