示例#1
0
        //---------------------------------------------------------------------------

        public void SetCurrentPath(int index)
        {
            Index = index;
            m_Paths[Index].Reset();

            TransformComponent transform = GetComponent <TransformComponent>();

            if (transform != null)
            {
                Keyframe frame;
                m_Paths[Index].GetNextKeyFrame(0.0f, out frame);

                transform.MoveTo(frame.Location);
                transform.RotateTo(frame.Rotation);
            }
        }
示例#2
0
        //---------------------------------------------------------------------------

        public void Tick(float deltaTime)
        {
            switch (State)
            {
            case EAnimationState.Playing:
                TransformComponent transform = GetComponent <TransformComponent>();
                PhysicsComponent   physics   = GetComponentInAncestor <PhysicsComponent>();

                if (transform != null)
                {
                    if (physics != null)
                    {
                        Keyframe frame;
                        if (m_Paths[Index].GetNextKeyFrame(deltaTime, out frame))
                        {
                            physics.ApplyAbsoluteForce(frame.Location - transform.Location);
                            //physics.RotateTo(frame.Rotation);
                        }
                        else
                        {
                            Stop();
                        }
                    }
                    else
                    {
                        Keyframe frame;
                        if (m_Paths[Index].GetNextKeyFrame(deltaTime, out frame))
                        {
                            transform.MoveTo(frame.Location);
                            transform.RotateTo(frame.Rotation);
                        }
                        else
                        {
                            Stop();
                        }
                    }
                }
                break;
            }
        }