private void Update() { if (_ragDoll) //Ragdollstate { _ragDollObject.SetActive(true); gameObject.SetActive(false); } if (_transformRoot.parent == _elevator.transform) //Inside the elevator { Vector3 Position = new Vector3(0, yOffset, 0); _transformRoot.localPosition = Position; } if (_moveForward) { Vector3 destinationPos = new Vector3(_myWaitPosition.transform.position.x, _transformRoot.position.y, _transformRoot.position.z); if (Vector3.Distance(_transformRoot.position, destinationPos) < 0.5f) { _animator.Idle(); _reachedWaitPos = true; OnReachedDestination?.Invoke(this); _moveForward = false; } if (!_reachedWaitPos) { _animator.Walk(); _transformRoot.position += Vector3.right * Time.deltaTime * movementSpeed; } } if (_moveToElevator) { _animator.Walk(); Vector3 destinationPos = new Vector3(_elevator.transform.position.x, _transformRoot.position.y, _transformRoot.position.z); if (!_insideTheElevator) { _transformRoot.position += Vector3.right * Time.deltaTime * movementSpeed; } } if (_runToElevator) { _animator.Run(); Vector3 destinationPos = new Vector3(_elevator.transform.position.x, _transformRoot.position.y, _transformRoot.position.z); if (!_insideTheElevator) { _transformRoot.position += Vector3.right * Time.deltaTime * movementSpeed * 2; } } }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("ElevatorDoor")) { if (!_insideTheElevator && (_elevator.IsStopedOnTheFloor(_currentFloor.Index)) && _elevator.HasRoom) { StopMovement(); _animator.Idle(); HandleInsideElevator(); } else { _ragDoll = true; AudioManager.instance.Play("Fall"); OnUserDied?.Invoke(); } } // return; /* * if (other.CompareTag("ElevatorDoor")) * { * if (!_insideTheElevator && !_moveToDespawn) * { * if (_elevator.IsStopedOnTheFloor(_currentFloor.Index) && _elevator.HasRoom) * { * HandleInsideElevator(); * StopMovement(); * } * else * { * _ragDoll = true; * AudioManager.instance.Play("Fall"); * OnUserDied?.Invoke(); * } * } * }*/ }