From dd5346f6f962c32d782d8fcfcc26477d4ae31086 Mon Sep 17 00:00:00 2001 From: Michael McKenzie Date: Tue, 25 Apr 2017 03:27:09 -0230 Subject: [PATCH] bug/error fixes. Ball resetting on triggers, animation warning, network table, unsused vars --- .../paddle-kednar/paddle_kednar1.controller | 6 ++++++ .../paddle-kednar2/k2_ani_cont.controller | 12 +++++++++--- Assets/scripts/entity/Ball.cs | 17 +++++++++-------- Assets/scripts/entity/PaddleNetworking.cs | 2 +- Assets/scripts/entity/powers/PowerManager.cs | 6 ++---- Assets/scripts/ui/BasicMenu.cs | 19 +++++++++++++++++-- 6 files changed, 44 insertions(+), 18 deletions(-) diff --git a/Assets/entities/paddle/paddle-kednar/paddle_kednar1.controller b/Assets/entities/paddle/paddle-kednar/paddle_kednar1.controller index 80c18e6..c57653f 100644 --- a/Assets/entities/paddle/paddle-kednar/paddle_kednar1.controller +++ b/Assets/entities/paddle/paddle-kednar/paddle_kednar1.controller @@ -14,6 +14,12 @@ AnimatorController: m_DefaultInt: 0 m_DefaultBool: 0 m_Controller: {fileID: 0} + - m_Name: hit + m_Type: 4 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 0} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer diff --git a/Assets/entities/paddle/paddle-kednar2/k2_ani_cont.controller b/Assets/entities/paddle/paddle-kednar2/k2_ani_cont.controller index 98428ca..81149a6 100644 --- a/Assets/entities/paddle/paddle-kednar2/k2_ani_cont.controller +++ b/Assets/entities/paddle/paddle-kednar2/k2_ani_cont.controller @@ -13,19 +13,25 @@ AnimatorController: m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} - m_Name: moving_L m_Type: 4 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} - m_Name: hit m_Type: 4 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} + - m_Name: pull + m_Type: 4 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 0} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer diff --git a/Assets/scripts/entity/Ball.cs b/Assets/scripts/entity/Ball.cs index d575308..67b8389 100644 --- a/Assets/scripts/entity/Ball.cs +++ b/Assets/scripts/entity/Ball.cs @@ -8,7 +8,7 @@ public class Ball : NetworkBehaviour { private Rigidbody rigidBody = null; - private Renderer renderer = null; + private new Renderer renderer = null; private TrailRenderer trailRenderer = null; private Vector3 startingPosition = Vector3.zero; float minimumVelocity = 5; @@ -127,15 +127,16 @@ public void ResetPosition() void OnTriggerEnter(Collider Col) { - // Respawn ball at center if on the server or local - ResetBall(); - - // Only handle scoring server-side of local - if (NetworkManager.singleton.isNetworkActive && NetworkServer.connections.Count == 0) return; - // If the ball collided with Goal1 or Goal2: if (Col.gameObject.tag == "Goal1" || Col.gameObject.tag == "Goal2") { + // Respawn ball at center if on the server or local + ResetBall(); + + // Only handle scoring server-side of local + if (NetworkManager.singleton.isNetworkActive && NetworkServer.connections.Count == 0) return; + + // If the ball collided with Goal1: if (Col.gameObject.tag == "Goal1") { @@ -173,7 +174,7 @@ void OnCollisionExit(Collision other) if (other.gameObject.tag == "Paddle" || other.gameObject.tag == "Bumper") { - Debug.Log ("Adding force to ball"); + //Debug.Log ("Adding force to ball"); rigidBody.AddForce (rigidBody.velocity.normalized * 2.5f); } } diff --git a/Assets/scripts/entity/PaddleNetworking.cs b/Assets/scripts/entity/PaddleNetworking.cs index 08acfdf..cb40c24 100644 --- a/Assets/scripts/entity/PaddleNetworking.cs +++ b/Assets/scripts/entity/PaddleNetworking.cs @@ -23,7 +23,7 @@ public class PaddleNetworking : NetworkBehaviour { [SyncVar] private int paddleIndex; - void OnStartClient () + new void OnStartClient () { // The paddle is by default AI controlled paddleClientId = PADDLE_AI; diff --git a/Assets/scripts/entity/powers/PowerManager.cs b/Assets/scripts/entity/powers/PowerManager.cs index 0378127..377fb5a 100644 --- a/Assets/scripts/entity/powers/PowerManager.cs +++ b/Assets/scripts/entity/powers/PowerManager.cs @@ -8,14 +8,13 @@ public class PowerManager : NetworkBehaviour { private const double nextPowerTimer = 30.0; - private GameObject paddle; private double timeSinceGivenPower; private Dictionary powerMapping; private bool isHost; private PaddleBase[] playerList; //Debugging - private uint ownerId; + //private uint ownerId; enum powerTypes { EMPTY, @@ -33,7 +32,6 @@ enum powerTypes { // Use this for initialization void Start () { - paddle = gameObject; timeSinceGivenPower = 0; //Host of online game or local game @@ -99,7 +97,7 @@ void giveNewPower(PaddleBase player) player.AddPower(powerName); - Debug.Log("Power Granted: " + powerMapping[(powerTypes)randInt].ToString() + " to player " + ownerId); + //Debug.Log("Power Granted: " + powerMapping[(powerTypes)randInt].ToString() + " to player " + ownerId); if (NetworkManager.singleton.isNetworkActive) { diff --git a/Assets/scripts/ui/BasicMenu.cs b/Assets/scripts/ui/BasicMenu.cs index 07854f3..edfbd64 100644 --- a/Assets/scripts/ui/BasicMenu.cs +++ b/Assets/scripts/ui/BasicMenu.cs @@ -162,7 +162,12 @@ void OnGUI() GUILayout.Label("The host is selecting a table..."); UndoCentered(); - TableNetworking tableNetworking = GameObject.FindGameObjectWithTag("TableNetworking").GetComponent(); + TableNetworking tableNetworking = null; + GameObject g = GameObject.FindGameObjectWithTag("TableNetworking"); + if (g) + { + tableNetworking = g.GetComponent(); + } if (tableNetworking != null && tableNetworking.ServerHasSelected()) { @@ -237,7 +242,17 @@ void OnGUI() case Menu.PaddleSelect: { - GUILayout.BeginHorizontal(); + try + { + GUILayout.BeginHorizontal(); + } + catch + { + //Changing the GUI creates an error here + // so we must wait until next repaint to draw + // gui elements + break; + } // GUI Padding GUILayout.Space(15); GUILayout.BeginVertical();