// Update is called once per frame void FixedUpdate() { if (canCrowdHop) { CheckForCrowd(); } _gravPull = _cGrav.gravitationalPull; if (_input && _GChecker.OnGround()) { Jump(jumpForce); } else if (_GChecker.OnGround()) { // Was moving vertically before hitting ground if (_mov.y != 0) { OnLandAirtimeEvent.Invoke(_airTime); OnLandEvent.Invoke(); } _fact.x = 1; _fact.z = 1; _mov.y = 0; _mov.z = 0; _airTime = 0; } if (!_GChecker.OnGround()) { _airTime += Time.deltaTime; _bonkingHead = _GChecker.CheckRay(bonkCheckRayOrigin, transform.up, bonkCheckRayRange); } if (_bonkingHead) { _fact.x = 1; _mov.y = 0; } MovementVector = _mov; FactorVector = _fact; }
// Update is called once per frame void Update() { if (canCrowdRun) { if (_GChecker.CheckRay(out _rayhit, crowdColliderLayer)) { _newCrowdCollider = _rayhit.collider; } else { _newCrowdCollider = null; } _onCrowd = (_currentCrowdCollider || _newCrowdCollider); if (_GChecker.OnGround()) { _onCrowd = false; _currentCrowdCollider = null; } /* else //If I have begun crowd running, i only stop when on ground * _onCrowd = !_GChecker.OnGround();*/ if (_onCrowd) { CrowdContact(_newCrowdCollider); if (_inContactComponent) { // multiply by constant to make it more user friendly to // evaluate _inContactComponent.EvaluateVelocity( (_velocity * _currentVelMod).magnitude * 10); } if (_slowDownTimer >= timeBeforeSlowDown.Value) { // How much has it gone since the slowdown started float currSlow = _slowDownTimer - timeBeforeSlowDown; // Check the curve to get the modifier for the speed [0-1] _currentVelMod = crowdVelocityModifier + slowDownCurve.Value.Evaluate(currSlow / crowdDecelerationTime); // print("VEL MOD:" + _currentVelMod); } else { _currentVelMod = 1; } } else { _slowDownTimer = 0; _currentVelMod = 1; } } AccelerateX(); AccelerateZ(); FactorVector = Vector3.one; MovementVector = _velocity * _currentVelMod; }