Exemple #1
0
        /// <summary>
        /// Resets the all the fields to default.
        /// </summary>
        public void Reset()
        {
            transform = null;

            kinematicPlatform = null;

            previousPosition = Vector3.zero;
            previousRotation = Quaternion.identity;
        }
Exemple #2
0
        /// <summary>
        /// Updates the dynamic ground info.
        /// </summary>
        public void UpdateTarget(KinematicPlatform kinematicPlatform, Vector3 characterPosition)
        {
            this.kinematicPlatform = kinematicPlatform;

            if (this.kinematicPlatform == null)
            {
                Reset();
                return;
            }

            this.transform = kinematicPlatform.transform;

            previousPosition = kinematicPlatform.RigidbodyComponent.Position;
            previousRotation = kinematicPlatform.RigidbodyComponent.Rotation;
        }
Exemple #3
0
 public void AddActor(KinematicPlatform kinematicPlatform)
 {
     kinematicPlatforms.Add(kinematicPlatform);
 }
Exemple #4
0
 public void RemoveActor(KinematicPlatform kinematicPlatform)
 {
     kinematicPlatforms.Remove(kinematicPlatform);
 }
Exemple #5
0
        /// <summary>
        /// Updates and interpolates all the actors in the scene.
        /// </summary>
        public void Simulate(float dt)
        {
            if (OnSimulationStart != null)
            {
                OnSimulationStart(dt);
            }

            for (int i = 0; i < kinematicPlatforms.Count; i++)
            {
                KinematicPlatform kinematicPlatform = kinematicPlatforms[i];

                if (!kinematicPlatform.enabled)
                {
                    continue;
                }

                kinematicPlatform.UpdateKinematicActor(dt);
            }

            if (OnCharacterSimulationStart != null)
            {
                OnCharacterSimulationStart(dt);
            }

            for (int i = 0; i < characterActors.Count; i++)
            {
                CharacterActor characterActor = characterActors[i];


                if (!characterActor.enabled)
                {
                    continue;
                }

                characterActor.UpdateCharacter(dt);
            }

            if (OnCharacterSimulationEnd != null)
            {
                OnCharacterSimulationEnd(dt);
            }



            // Interpolation ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────

            if (useInterpolation)
            {
                for (int i = 0; i < kinematicPlatforms.Count; i++)
                {
                    KinematicPlatform kinematicPlatform = kinematicPlatforms[i];

                    if (!kinematicPlatform.enabled)
                    {
                        continue;
                    }

                    InterpolateRigidbodyComponent(kinematicPlatform.RigidbodyComponent);
                }

                // for( int i = 0 ; i < characterActors.Count ; i++ )
                // {
                //     CharacterActor characterActor = characterActors[i];

                //     if( !characterActor.enabled || !characterActor.IsKinematic )
                //         continue;

                //     InterpolateRigidbodyComponent( characterActor.RigidbodyComponent );
                // }
            }


            if (OnSimulationEnd != null)
            {
                OnSimulationEnd(dt);
            }
        }