void Update() { if (hitPreDeathTrigger) { return; } horizontalInput = Input.GetAxis("J" + playerNumber + "_Horizontal"); verticalInput = Input.GetAxis("J" + playerNumber + "_Vertical"); pushInput = Input.GetButtonDown("J" + playerNumber + "_A"); movingDirection = new Vector3(horizontalInput, 0f, verticalInput).normalized; if (pushInput) { PlayAudio(pushAudio); GameObject particles = Instantiate(particlesPrefab.gameObject, particleTransform.position, particleTransform.rotation) as GameObject; ParticleSystem _particles = particles.GetComponent <ParticleSystem>(); Renderer particlesRenderer = _particles.GetComponent <Renderer>(); particlesRenderer.material.color = componentOwner.playerColor; Destroy(particles, particlesLifetime); Collider[] colliders = Physics.OverlapSphere(pushTransform.position, hitDistance, targetLayer); if (colliders.Length != 0) { for (int i = 0; i < colliders.Length; i++) { Rigidbody targetRigidbody = colliders[i].GetComponent <Rigidbody>(); PlayerControl1 targetPlayerControl = colliders[i].GetComponent <PlayerControl1>(); if (!targetRigidbody || !targetPlayerControl) { continue; } if (targetPlayerControl.componentOwner == componentOwner) { continue; } if (targetPlayerControl.currentCoroutine != null) { targetPlayerControl.StopCoroutine(targetPlayerControl.currentCoroutine); targetPlayerControl.lastPlayerTouched = null; } targetPlayerControl.lastPlayerTouched = componentOwner; targetPlayerControl.currentCoroutine = targetPlayerControl.ResetLastPlayerTouched(targetPlayerControl.touchResetTime); targetRigidbody.AddForce((targetRigidbody.position - transform.position) * pushPower, ForceMode.Impulse); targetPlayerControl.StartCoroutine(targetPlayerControl.currentCoroutine); } } } }
// Update is called once per frame void Update() { if (m_bReadyRestart == true) { if (Input.GetKeyUp(KeyCodeRestart) == true) { m_bReadyRestart = false; GameObjectNotifyRestartGame.gameObject.SetActive(false); if (m_playerCtrl != null) { m_playerCtrl.StartCoroutine(m_playerCtrl.DelayLoadScene()); } } } }