/*public void SetController(ref GameInput.Controller _myController) * { * myController = _myController; * botHandler = new BotLogic.BotHandler(transform, ref myController); * navSystem = arenaMaster.GetComponent<arenaGen>().navSystem; * }*/ public void SetController(GameInput.Controller _myController) { myController = _myController; Debug.Log(myController.index); if (myController.index == -1) { isBot = true; navSystem = arenaMaster.GetComponent <arenaGen>().navSystem; botHandler = new BotLogic.BotHandler(transform, ref myController, reactionTime); } }
void InputHandling() { /*if (botHandler == null) { botHandler = new BotLogic.BotHandler(transform, ref myController); } * Vector3 avoidance = botHandler.CollisionAvoidance(); * Debug.Log(avoidance); * if (avoidance != Vector3.zero) * { * //lookAt = false; * //shouldBoost = false; * myController.angle = Vector3.zero; * //myController.movement = Vector3.zero; * myController.angle.x = avoidance.y; * myController.angle.y = -avoidance.x; * //myController.movement.x = avoidance.y; * //myController.movement.y = avoidance.x; * //Vector3.SmoothDamp() * myController.movement.z = 1; * //shouldAccelerate = false; * }/**/ if (isBot) { if (myController == null) { SetController(new GameInput.Controller(GameInput.ControllerType.xbox, -1)); navSystem = arenaMaster.GetComponent <arenaGen>().navSystem; botHandler = new BotLogic.BotHandler(transform, ref myController, reactionTime); } BotUpdate(); } else if (selfUpdate) { myController.Update(); } moveVector = myController.movement; spinVector = myController.angle; isBoosting = myController.isBoosting; isBraking = myController.isBraking; if (isBoosting) { spinVector = Vector3.zero; } if (myController.isFire1Down) { BroadcastMessage("Fire1Down"); } if (myController.isFire1Up) { BroadcastMessage("Fire1Up"); } if (myController.isFire2Down) { BroadcastMessage("Fire2Down"); } if (myController.isFire2Up) { BroadcastMessage("Fire2Up"); } spinVector = transform.localToWorldMatrix.MultiplyVector(spinVector * sensitivity); /* Aim Assist system * Lowers sensitivity and makes movement axis linear while player is aiming within a few degrees of an enemy * Should prefer enemy the closest to the center of screen * Should "nudge" the controller along target's relative motion (not yet implimented) * currently disabled because it sucks */ /*if (aimAssist) * { * myController.useLookCurve = true; * GameObject enemy = null; * float minDiff = float.MaxValue; * float angDiff; * for (int i = 0; i < enemies.Count; i++) * { * if (botHandler == null) { botHandler = new BotLogic.BotHandler(transform, ref myController); } * angDiff = botHandler.isVisibleAngle(transform.forward, transform.position, enemies[i].transform.position); * if (!float.IsNaN(angDiff)) * { * if (angDiff < minDiff) { enemy = enemies[i];minDiff = angDiff; } * } * } * angDiff = minDiff; * if (enemy != null) * { * if (angDiff < aimAssistInnerAngle) * { * spinVector *= aimAssistAltDampen; * myController.useLookCurve = false; * } * else if (angDiff < aimAssistAngle) * { * spinVector *= aimAssistDampen; * myController.useLookCurve = false; * } * } * }/**/ myRb.angularVelocity = spinVector; if (health < 0) { //transform.GetChild() if (!isBot) { GameObject tempObject = Instantiate(spectator, transform.position, transform.rotation); tempObject.SetActive(true); tempObject.GetComponent <Camera>().enabled = false; tempObject.GetComponent <SpectatorScript>().SetController(myController); myCamera.transform.SetParent(tempObject.transform); targetUi.transform.SetParent(tempObject.transform); targetUi.transform.GetChild(2).gameObject.SetActive(true); } gameObject.SetActive(false); } /*if (myController.isStealthDown) * { * inStealth = !inStealth; * if (inStealth) { BroadcastMessage("StealthModeActivate"); } * else { BroadcastMessage("StealthModeDeactivate"); } * }*/ }