void OnTriggerExit2D(Collider2D collision) { RespawnScript respawn = collision.gameObject.GetComponent <RespawnScript>(); if (respawn != null) { respawn.Respawn(); } }
void OnTriggerEnter(Collider col) { RespawnScript rs = col.GetComponent <RespawnScript>(); if (rs != null) { rs.Respawn(); } }
private void OnCollisionStay(Collision collision) { _respawntimer += Time.deltaTime; if (_respawntimer > _respawnTime) { //if car is tilted if (!CheckIfAnyWheelsAreGrounded()) { _respawnScript.Respawn(); } else //if wheels are on ground but car is hitting wall { //temp code, may be removed if (_carRigidbody.velocity.magnitude < 4) { _respawnScript.Respawn(); } } _respawntimer = 0; } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag.Equals("Ball")) { Ball ball = other.gameObject.GetComponent <Ball>(); RespawnScript respawn = other.gameObject.GetComponent <RespawnScript>(); Score(ball.GetTeam()); ball.SetTeam(Team.NONE); respawn.Respawn(); } else if (other.gameObject.tag.Equals("Player")) { RespawnScript respawn = other.gameObject.GetComponent <RespawnScript>(); respawn.Respawn(); } }
public void Update() { if (_pauseMenu.IsPaused) { return; } _anywheelsGrounded = CheckIfAnyWheelsAreGrounded(); _steerLeft = 0; _steerRight = 0; _brake = 0; _gas = 0; if (_countDownScript.ShowCountDown) // if countdown is still bussy you cannot use the car { return; } for (int i = 0; i < _controllers.Count; i++) { //STEERING + GAS & BREAK float axisInput = Input.GetAxis("A" + _controllers[i] + "_Axis"); //Debug.Log("controller " + i + ": " + _controllers[i]); GlowCharacterIfClickOnButtonA(i); // if you click on button the character is glowing switch (_playerPositions[i]._position) { case Positions.SteerLeft: { _steerLeft += _maxSteeringAngle * axisInput / 2; //set playeractions to neutral - audio related if (axisInput != 0) { PlayerActionsSteering[i] = -1; } else { PlayerActionsSteering[i] = 0; } PlayerActionsAcceleration[i] = 0; } break; case Positions.SteerRight: { _steerRight += _maxSteeringAngle * axisInput / 2; //set playeractions to neutral - audio related if (axisInput != 0) { PlayerActionsSteering[i] = 1; } else { PlayerActionsSteering[i] = 0; } PlayerActionsAcceleration[i] = 0; } break; case Positions.Brake: { _brake += _maxMotorTorque * axisInput / 2; //adjust playeractions accordingly - audio related if (axisInput != 0) { PlayerActionsAcceleration[i] = -1; } else { PlayerActionsAcceleration[i] = 0; } PlayerActionsSteering[i] = 0; } break; case Positions.Gas: { _gas += _maxMotorTorque * axisInput / 2; //adjust playeractions accordingly - audio related if (axisInput != 0) { PlayerActionsAcceleration[i] = 1; } else { PlayerActionsAcceleration[i] = 0; } PlayerActionsSteering[i] = 0; } break; } //MID-AIR ROTATING if (!_anywheelsGrounded) { float RightAxisInputX = Input.GetAxis("J" + _controllers[i] + "_RightHorizontal"); float RightAxisInputY = Input.GetAxis("J" + _controllers[i] + "_RightVertical"); //get current rotation of car Vector3 tempRotation = transform.eulerAngles; //lerp to rotation of ground tempRotation.x += -(_midAirRotationSpeed / _controllers.Count) * RightAxisInputY * Time.deltaTime; tempRotation.z += -(_midAirRotationSpeed / _controllers.Count) * RightAxisInputX * Time.deltaTime; //set rotation transform.rotation = Quaternion.Euler(tempRotation); } } //calculate acceleration level - audio related AccelerationLevel = PlayerActionsAcceleration[0] + PlayerActionsAcceleration[1] + PlayerActionsAcceleration[2] + PlayerActionsAcceleration[3]; SteeringLevel = PlayerActionsSteering[0] + PlayerActionsSteering[1] + PlayerActionsSteering[2] + PlayerActionsSteering[3]; //RESPAWNING //if any player is holding "b" show respawnbar if (CheckIfAnyPlayerIsHoldingB()) { _respawnPanel.SetActive(true); } else { _respawnPanel.SetActive(false); } //if all players are holding "b", start respawntimer //when timer hits respawn time, respawn if (CheckIfAllPlayersAreHoldingB()) { _respawnTimer += Time.deltaTime; if (_respawnTimer > _respawnTime) { _respawnScript.Respawn(); _respawnTimer = 0; } } else { _respawnTimer = 0; } _respawnBar.value = _respawnTimer / _respawnTime; }
void OnDestroy() { RS.Respawn(PlayerNumber); Destroy(AimingCursor.gameObject); }