private void OnTriggerEnter(Collider other) { Movement.KnockbackBehaviour knockbackScript = other.transform.root.GetComponent <Movement.KnockbackBehaviour>(); Gameplay.CharacterDefenseBehaviour defenseScript = other.transform.root.GetComponent <Gameplay.CharacterDefenseBehaviour>(); if (!knockbackScript) { return; } else if (knockbackScript.IsInvincible || knockbackScript.Landing || knockbackScript.InFreeFall) { return; } //Don't add a force if the object is traveling at a low speed if (knockbackScript.Physics.LastVelocity.magnitude <= 0.1f || knockbackScript.Physics.Bounciness <= 0 || !knockbackScript.Physics.PanelBounceEnabled) { return; } float upMagnitude = knockbackScript.Physics.LastVelocity.magnitude * knockbackScript.Physics.Bounciness; //Calculate and apply friction force upMagnitude /= _bounceDampening; knockbackScript.Physics.ApplyImpulseForce(Vector3.up * upMagnitude); knockbackScript.CancelHitStun(); }
// Start is called before the first frame update void Start() { _moveset = GetComponent <Gameplay.MovesetBehaviour>(); _stateMachine = GetComponent <Gameplay.CharacterStateMachineBehaviour>().StateMachine; _knockbackBehaviour = GetComponent <Movement.KnockbackBehaviour>(); }