Esempio n. 1
0
 void Start()
 {
     basicMover      = new BasicMover(m_animator);
     strafeMover     = new StrafeMover(m_animator);
     swordMover      = new SwordMover(m_animator);
     moveMentCommand = basicMover;
     moveMentCommand.Excecute();
 }
Esempio n. 2
0
    public void Jump()
    {
        if (!m_jumping && !m_falling)
        {
            m_rigidbody.useGravity = true;
            m_jumping  = true;
            m_grounded = false;
            if (m_walled)
            {
                //Debug.Log("wall jump!");
                m_rigidbody.AddForce(Vector3.up * m_jumpForce, ForceMode.Impulse);

                Vector3 intoWall = Vector3.Project(m_moveInput, m_wallAt.contacts[0].normal);
                float   wallJump = 1.0f - smoothstep(0.5f, 0.9f, intoWall.magnitude * (1.0f - clamp(Vector3.Dot(intoWall, m_wallAt.contacts[0].normal), 0.0f, 1.0f)));

                m_rigidbody.AddForce(m_wallAt.contacts[0].normal * m_jumpForce * wallJump, ForceMode.Impulse);
            }
            else
            {
                //Debug.Log("ground jump!");
                m_rigidbody.AddForce(Vector3.up * m_jumpForce, ForceMode.Impulse);
            }

            //Jumping off moving platform; maintain momementum
            if (transform.parent != null)
            {
                BasicSpinner spinner = transform.parent.GetComponent <BasicSpinner>();
                if (spinner != null)
                {
                    m_rigidbody.velocity += spinner.GetVelocityAt(m_groundAt.point);
                }

                BasicMover mover = transform.parent.GetComponent <BasicMover>();
                if (mover != null)
                {
                    m_rigidbody.velocity += mover.GetVelocity();
                }

                if (m_groundAt.collider != null)
                {
                    Rigidbody body = m_groundAt.collider.GetComponent <Rigidbody>();
                    if (body != null)
                    {
                        m_rigidbody.velocity += body.velocity;
                    }
                }

                transform.parent = null;
            }
        }
    }