public GamePhysics.Knock DisplayKnockFields(string label, GamePhysics.Knock knock) { GamePhysics.Knock newKnock = knock; EditorGUILayout.LabelField(label); newKnock.Angle = EditorGUILayout.FloatField("Angle", newKnock.Angle); newKnock.Force = EditorGUILayout.FloatField("Force", newKnock.Force); newKnock.Speed = EditorGUILayout.FloatField("Speed", newKnock.Speed); return(newKnock); }
void KnockMotion(GamePhysics.Knock knock) { Vector3 lastPosition = transform.localPosition; Vector3 newPosition = MathHelper.GetBallisticMotion(knock.Angle, knock.Force, -Physics.gravity.y, m_CurrentKnockTime, m_HorizontalDir); m_CurrentKnockTime += knock.Speed * Time.deltaTime; Vector3 direction = (m_KnockStartPosition + newPosition - lastPosition); m_CharacterController.Move(direction); if (m_CharacterController.isGrounded) { m_LaunchDirection = LaunchDirection.NO_LAUNCH; if (OnKnockback != null) { OnKnockback(); } } }