Exemple #1
0
        private Vector2 GetShotAngle(Vector2 shotVector)
        {
            Vector2 shotAngle;

            if (shootAtMouse)
            {
                //Angle between mouse and right vector 0-360 deg
                shotAngle = SelfRotation.ComputeTotalAngle(shotVector, Vector3.right);
            }
            else
            {
                shotAngle = hinge.transform.rotation.eulerAngles;
            }

            return(shotAngle);
        }
Exemple #2
0
        private Vector2 GetShotVector()
        {
            Vector2 shotVector;

            if (shootAtMouse)
            {
                //Vector between mouse and current position
                Vector3 mouseVector = Camera.main.ScreenToWorldPoint(Input.mousePosition) - new Vector3(Blob.position.x, Blob.position.y, 0);
                shotVector = new Vector2(mouseVector.x, mouseVector.y);
                shotVector = shotVector.normalized;
            }
            else
            {
                shotVector = SelfRotation.DegreeToVector2(hinge.transform.rotation.eulerAngles.z);
                // Shoot left when player is looking left
                if (transform.right.x == -1f)
                {
                    shotVector *= new Vector2(-1, 1);
                }
            }

            return(shotVector);
        }