diff --git a/JustJuggle/Assets/Scripts/HandleCatch.cs b/JustJuggle/Assets/Scripts/HandleCatch.cs index 3ef3b3c..87333de 100644 --- a/JustJuggle/Assets/Scripts/HandleCatch.cs +++ b/JustJuggle/Assets/Scripts/HandleCatch.cs @@ -25,11 +25,6 @@ public class HandleCatch : MonoBehaviour { - // public variables - [Header("Scoring")] - [Tooltip("Flag for if object has been thrown (used to prevent catching object and getting bonus input at same time)")] - public bool objectNearHand = false; - [Header("Objects")] [Tooltip("Player hand attached to this script")] @@ -47,6 +42,7 @@ public class HandleCatch : MonoBehaviour public int leftHandX = 1; public int rightHandX = -1; + private int thisHandX = 0; public double xDeviation = 0.25; [Header("Inputs")] @@ -56,6 +52,21 @@ public class HandleCatch : MonoBehaviour [Tooltip("Actual input from player")] string playerInput = ""; + // Start is called before the first frame update + void Start() + { + // get this hand's x position + if( playerHand.transform.position.x > 0 ) + { + thisHandX = leftHandX; + } + else + { + thisHandX = rightHandX; + } + + } + // Update is called once per frame void Update() { @@ -93,7 +104,7 @@ void CheckForObjectThrow() } // check for trigger collision with juggling object - if( objectNearHand && collidedObjects.Contains(jugglingObject) ) + if( collidedObjects.Contains(jugglingObject) ) { // get input juggling oject is expecting expectedInput = jugglingObject.GetComponent().expectedInput; @@ -149,27 +160,18 @@ void FindJugglingObjects() void OnTriggerEnter(Collider other) { - // check if object is juggling object - if( other.gameObject.tag == "Proximity" ) + // check if object is juggling object going to this hand + if( other.gameObject.tag == "Proximity" && + other.gameObject.transform.parent.gameObject.GetComponent().destinationHand == thisHandX ) { - - // lock out bonus input if object is near hand - objectNearHand = true; collidedObjects.Add(other.gameObject.transform.parent.gameObject); } } void OnTriggerExit(Collider other) { - // check if object is juggling object - if( other.gameObject.tag == "Proximity" ) - { - // allow bonus input if object is no longer near hand - objectNearHand = false; - - // remove object from collided objects list - collidedObjects.Remove(other.gameObject.transform.parent.gameObject); - } + // remove object from collided objects list + collidedObjects.Remove(other.gameObject.transform.parent.gameObject); } // Update player score @@ -182,7 +184,6 @@ void UpdateScore( UnityEngine.Vector3 handPos, UnityEngine.Vector3 objectPos, bo // if input is wrong subtract score instead of adding if( wrongInput ) { - Debug.Log("\t\tScore Mult: " + scoreMult); scoreMult = -scoreMult; } diff --git a/JustJuggle/Assets/Scripts/JugglingObject.cs b/JustJuggle/Assets/Scripts/JugglingObject.cs index c690ee4..8f110e5 100644 --- a/JustJuggle/Assets/Scripts/JugglingObject.cs +++ b/JustJuggle/Assets/Scripts/JugglingObject.cs @@ -111,13 +111,9 @@ void FixedUpdate() public void MoveObject() { // get position of juggling object - float objectHeight = jugglingObject.transform.position.y*dpi; float objectX = jugglingObject.transform.position.x; + float objectHeight = jugglingObject.transform.position.y*dpi; - if( Math.Abs(objectX) >= Math.Abs(destinationX/dpi) ) - { - xStep = 0; - } if( objectHeight >= maxHeight ) { yStep = -yStep; @@ -213,10 +209,10 @@ void UpdateDestination() // get x position of hand (hand location +/- deviation) // this will make the look of the juggling more natural since the hands will not always be in the same place - destinationX = (destinationHand + UnityEngine.Random.Range(-(float)xDeviation, (float)xDeviation)) * dpi; // convert to pixels + destinationX = (destinationHand + UnityEngine.Random.Range(-(float)xDeviation, (float)xDeviation)) * dpi; // save step size - xStep = destinationX - currentPos / framesUntilIntercept; + xStep = (destinationX - currentPos) / framesUntilIntercept; // slow down time xStep /= slowFactor; @@ -227,6 +223,8 @@ void UpdateDestination() // update position oldPosition = jugglingObject.transform.position; + + Debug.Log("Xstep: " + xStep ); // throw throwing = true; diff --git a/JustJuggle/Assets/Scripts/JustJugglingMain.cs b/JustJuggle/Assets/Scripts/JustJugglingMain.cs index 6a7ac0b..65e965d 100644 --- a/JustJuggle/Assets/Scripts/JustJugglingMain.cs +++ b/JustJuggle/Assets/Scripts/JustJugglingMain.cs @@ -71,7 +71,6 @@ static public void OBJ_HIT( float scoreMult ) // subtractive scoring for failed inputs else { - Debug.Log("Score Mult: " + scoreMult); Script.playerScore += (int)(Script.scoreAdd * scoreMult); }