/*
     * \brief Works out if a value is almost another value (for floating point accuracy)
     */
    public void CallOnCollisionEnter(Collision collision)
    {
        m_collisionState = CollisionState.None;

        foreach (ContactPoint contact in collision)
        {
            m_platform = contact.otherCollider.gameObject.GetComponent <CSceneObjectPlatform>();
            if (m_platform != null)
            {
                m_platform.resetDeltaA();
            }
            if (isNearly(contact.normal.y, 1.0f, 0.2f))
            {
                m_collisionState = CollisionState.OnFloor;

                // are we on a special material?
                m_footMaterial = FootMaterial.Stone;
                if (contact.otherCollider.tag == "Wood Object")
                {
                    m_footMaterial = FootMaterial.Wood;
                }
                else if (contact.otherCollider.tag == "Metal Object")
                {
                    m_footMaterial = FootMaterial.Metal;
                }
            }
            else if (isNearly(contact.normal.y, -1.0f, 0.2f))
            {
                m_collisionState = CollisionState.OnRoof;
            }
            else
            {
                m_collisionState    = CollisionState.OnWall;
                m_ladderClimb.State = LadderState.None;
            }
        }

        if (m_collisionState == CollisionState.OnFloor)
        {
            if (m_jumpState != JumpState.Landed)
            {
                m_player.GetPlayerAnimation().PlayFootstepAudio(m_footMaterial);
            }

            m_jumpState         = JumpState.Landed;
            m_ladderClimb.State = LadderState.None;

            if (m_player.GetPlayerState() != PlayerState.Turning)
            {
                m_player.SetPlayerState(PlayerState.Standing);
            }

            //m_ledgeGrabBox.collider.enabled = true;
        }
    }
/*
 * \brief Called whilst a collision is taking place
 */
    public void CallOnCollisionStay(Collision collision, ref PlayerState playerState, ref float playerAlpha)
    {
        m_collisionState = CollisionState.None;

        foreach (ContactPoint contact in collision)
        {
            Debug.DrawRay(contact.point, contact.normal);

            //
            if (contact.otherCollider != null && contact.otherCollider.gameObject != null)
            {
                CSceneObjectPlatform platform = contact.otherCollider.gameObject.GetComponent <CSceneObjectPlatform>();
                if (platform != null && m_platform == null)
                {
                    m_platform = platform;
                    m_platform.resetDeltaA();
                }
            }

            //
            CSceneObject obj = null;
            if (contact.otherCollider)
            {
                obj = contact.otherCollider.gameObject.GetComponent <CSceneObject>();
                if (obj == null && contact.otherCollider.gameObject.transform.parent != null)
                {
                    GameObject parent = contact.otherCollider.gameObject.transform.parent.gameObject;
                    if (parent != null)
                    {
                        obj = parent.GetComponent <CSceneObject>();
                    }
                }
            }

            if (contact.thisCollider != null && contact.thisCollider.gameObject != null && contact.thisCollider.gameObject.name == "Ledge_Grab_Detection" && (obj == null || obj.CanLedgeGrab))
            {
                if (CSceneObject.CheckLedgeGrab(collision))
                {
                    continue;
                }
            }

            if (contact.otherCollider != null && contact.otherCollider.gameObject != null && contact.otherCollider.gameObject.name == "Ledge_Grab_Detection" && (obj == null || obj.CanLedgeGrab))
            {
                if (CSceneObject.CheckLedgeGrab(collision))
                {
                    continue;
                }
            }

            // wall jumping
            if (obj != null && obj.CanWallJump == true && m_jumpState != JumpState.Landed && !isNearly(contact.normal.y, 1.0f, 0.2f) && !isNearly(contact.normal.y, -1.0f, 0.1f))
            {
                m_collisionState         = CollisionState.OnWall;
                playerState              = PlayerState.WallJumpStart;
                m_jumpTimer              = (Time.time * 1000.0f);
                m_body.constraints       = RigidbodyConstraints.FreezeAll;
                m_velocity               = 0.0f;
                m_wallJump.StartHangTime = Time.time * 1000.0f;
            }
            // floor check
            else if (isNearly(contact.normal.y, 1.0f, 0.8f))
            {
                m_collisionState = CollisionState.OnFloor;
                if (!isNearly(contact.normal.y, 1.0f, 0.15f) && collision.contacts.Length == 1)
                {
                    m_velocity          = (m_movingDirection * 0.15f);
                    m_velocityLockTimer = (Time.time * 1000.0f);
                }

                // are we on a special material?
                m_footMaterial = FootMaterial.Stone;
                if (contact.otherCollider.tag == "Wood Object")
                {
                    m_footMaterial = FootMaterial.Wood;
                }
                else if (contact.otherCollider.tag == "Metal Object")
                {
                    m_footMaterial = FootMaterial.Metal;
                }
            }
            // head check
            else if (isNearly(contact.normal.y, -1.0f, 0.1f))
            {
                m_collisionState = CollisionState.OnRoof;
            }
            // wall check
            else
            {
                if (isFacingCollision(m_movingDirection, m_body.transform.position, contact.point, playerAlpha))
                {
                    m_collisionState = CollisionState.OnWall;
                    break;
                }
            }
        }

        if (m_collisionState == CollisionState.OnWall && m_jumpState == JumpState.Jumping && playerState != PlayerState.WallJumpStart)
        {
            m_velocity = -(m_movingDirection * 0.15f);
        }

        if (m_collisionState == CollisionState.OnFloor && ((Time.time * 1000.0f) - m_jumpTimer > 200.0f))
        {
            m_jumpState = JumpState.Landed;

            if (m_ladderClimb.State != LadderState.AtBase)
            {
                m_ladderClimb.State = LadderState.None;
            }
            else
            {
                playerState = PlayerState.UpALadder;
            }

            if (m_player.GetPlayerState() != PlayerState.Turning)
            {
                m_player.SetPlayerState(PlayerState.Standing);
            }
            //m_ledgeGrabBox.collider.enabled = true;
        }
    }
 /*
  * \brief Called when the player leaves a collosion
  */
 public void CallOnCollisionExit(Collision collision)
 {
     //m_collisionState = CollisionState.None;
     m_platform = null;
 }
 /*
  * \brief Called when the player leaves a collosion
 */
 public void CallOnCollisionExit(Collision collision)
 {
     //m_collisionState = CollisionState.None;
     m_platform = null;
 }
    /*
     * \brief Called whilst a collision is taking place
    */
    public void CallOnCollisionStay(Collision collision, ref PlayerState playerState, ref float playerAlpha)
    {
        m_collisionState = CollisionState.None;

        foreach (ContactPoint contact in collision)
        {
            Debug.DrawRay(contact.point, contact.normal);

            //
            if (contact.otherCollider != null && contact.otherCollider.gameObject != null)
            {
                CSceneObjectPlatform platform = contact.otherCollider.gameObject.GetComponent<CSceneObjectPlatform>();
                if (platform != null && m_platform == null) {
                    m_platform = platform;
                    m_platform.resetDeltaA();
                }
            }

            //
            CSceneObject obj = null;
            if (contact.otherCollider)
            {
                obj = contact.otherCollider.gameObject.GetComponent<CSceneObject>();
                if (obj == null && contact.otherCollider.gameObject.transform.parent != null) {
                    GameObject parent = contact.otherCollider.gameObject.transform.parent.gameObject;
                    if (parent != null) {
                        obj = parent.GetComponent<CSceneObject>();
                    }
                }
            }

            if (contact.thisCollider != null && contact.thisCollider.gameObject != null && contact.thisCollider.gameObject.name == "Ledge_Grab_Detection" && (obj == null || obj.CanLedgeGrab))
            {
                if(CSceneObject.CheckLedgeGrab(collision))
                    continue;
            }

            if (contact.otherCollider != null && contact.otherCollider.gameObject != null && contact.otherCollider.gameObject.name == "Ledge_Grab_Detection" && (obj == null || obj.CanLedgeGrab))
            {
                if (CSceneObject.CheckLedgeGrab(collision))
                    continue;
            }

            // wall jumping
            if (obj != null && obj.CanWallJump == true && m_jumpState != JumpState.Landed && !isNearly(contact.normal.y, 1.0f, 0.2f) && !isNearly(contact.normal.y, -1.0f, 0.1f))
            {
                m_collisionState = CollisionState.OnWall;
                playerState = PlayerState.WallJumpStart;
                m_jumpTimer = (Time.time * 1000.0f);
                m_body.constraints = RigidbodyConstraints.FreezeAll;
                m_velocity = 0.0f;
                m_wallJump.StartHangTime = Time.time * 1000.0f;
            }
            // floor check
            else if (isNearly(contact.normal.y, 1.0f, 0.8f))
            {
                m_collisionState = CollisionState.OnFloor;
                if (!isNearly(contact.normal.y, 1.0f, 0.15f) && collision.contacts.Length == 1)
                {
                    m_velocity = (m_movingDirection * 0.15f);
                    m_velocityLockTimer = (Time.time * 1000.0f);
                }

                // are we on a special material?
                m_footMaterial = FootMaterial.Stone;
                if (contact.otherCollider.tag == "Wood Object")
                    m_footMaterial = FootMaterial.Wood;
                else if (contact.otherCollider.tag == "Metal Object")
                    m_footMaterial = FootMaterial.Metal;
            }
            // head check
            else if (isNearly(contact.normal.y, -1.0f, 0.1f))
            {
                m_collisionState = CollisionState.OnRoof;
            }
            // wall check
            else
            {
                if (isFacingCollision(m_movingDirection, m_body.transform.position, contact.point, playerAlpha)) {
                    m_collisionState = CollisionState.OnWall;
                    break;
                }
            }
        }

        if (m_collisionState == CollisionState.OnWall && m_jumpState == JumpState.Jumping && playerState != PlayerState.WallJumpStart)
        {
            m_velocity = -(m_movingDirection * 0.15f);
        }

        if (m_collisionState == CollisionState.OnFloor && ((Time.time * 1000.0f) - m_jumpTimer > 200.0f))
        {
            m_jumpState = JumpState.Landed;

            if (m_ladderClimb.State != LadderState.AtBase)
            {
                m_ladderClimb.State = LadderState.None;
            }
            else
            {
                playerState = PlayerState.UpALadder;
            }

            if (m_player.GetPlayerState() != PlayerState.Turning) m_player.SetPlayerState(PlayerState.Standing);
            //m_ledgeGrabBox.collider.enabled = true;
        }
    }
    /*
     * \brief Works out if a value is almost another value (for floating point accuracy)
    */
    public void CallOnCollisionEnter(Collision collision)
    {
        m_collisionState = CollisionState.None;

        foreach (ContactPoint contact in collision)
        {
            m_platform = contact.otherCollider.gameObject.GetComponent<CSceneObjectPlatform>();
            if (m_platform != null) {
                m_platform.resetDeltaA();
            }
            if (isNearly(contact.normal.y, 1.0f, 0.2f))
            {
                m_collisionState = CollisionState.OnFloor;

                if (m_player.GetPlayerState() == PlayerState.OnLadder)
                {
                    GetLadder.state = LadderState.AtBase;
                    m_player.SetPlayerState(PlayerState.Standing);
                }

                // are we on a special material?
                m_footMaterial = FootMaterial.Stone;
                if (contact.otherCollider.tag == "Wood Object")
                    m_footMaterial = FootMaterial.Wood;
                else if (contact.otherCollider.tag == "Metal Object")
                    m_footMaterial = FootMaterial.Metal;

            }
            else if (isNearly(contact.normal.y, -1.0f, 0.2f))
            {
                m_collisionState = CollisionState.OnRoof;
                if (contact.otherCollider != null && contact.otherCollider.GetComponent<CSceneObjectPlatform>() != null)
                {
                    m_player.PushPlayerFromTower();
                }
            }
            else
            {
                if (m_player.GetPlayerState() != PlayerState.OnLadder)
                    m_collisionState = CollisionState.OnWall;
            }
        }

        if (m_collisionState == CollisionState.OnFloor)
        {
            if (m_jumpState != JumpState.Landed)
                m_player.GetPlayerAnimation().PlayFootstepAudio(m_footMaterial);

            m_jumpState = JumpState.Landed;

            if (GetLadder.state == LadderState.JumpingOff)
                GetLadder.state = LadderState.None;

            if (m_player.GetPlayerState() != PlayerState.Turning && m_player.GetPlayerState() != PlayerState.OnLadder && !m_player.PullingLever(false))
            {
                m_player.SetPlayerState(PlayerState.Standing);
            }
        }
    }
    /*
     * \brief Works out if a value is almost another value (for floating point accuracy)
    */
    public void CallOnCollisionEnter(Collision collision)
    {
        m_collisionState = CollisionState.None;

        foreach (ContactPoint contact in collision)
        {
            m_platform = contact.otherCollider.gameObject.GetComponent<CSceneObjectPlatform>();
            if (m_platform != null) {
                m_platform.resetDeltaA();
            }
            if (isNearly(contact.normal.y, 1.0f, 0.2f))
            {
                m_collisionState = CollisionState.OnFloor;

                // are we on a special material?
                m_footMaterial = FootMaterial.Stone;
                if (contact.otherCollider.tag == "Wood Object")
                    m_footMaterial = FootMaterial.Wood;
                else if (contact.otherCollider.tag == "Metal Object")
                    m_footMaterial = FootMaterial.Metal;

            }
            else if (isNearly(contact.normal.y, -1.0f, 0.2f))
            {
                m_collisionState = CollisionState.OnRoof;
            }
            else
            {
                m_collisionState = CollisionState.OnWall;
                m_ladderClimb.State = LadderState.None;
            }
        }

        if (m_collisionState == CollisionState.OnFloor)
        {
            if (m_jumpState != JumpState.Landed)
                m_player.GetPlayerAnimation().PlayFootstepAudio(m_footMaterial);

            m_jumpState = JumpState.Landed;
            m_ladderClimb.State = LadderState.None;

            if (m_player.GetPlayerState() != PlayerState.Turning) m_player.SetPlayerState(PlayerState.Standing);

            //m_ledgeGrabBox.collider.enabled = true;
        }
    }
示例#8
0
/*
 * \brief Called whilst a collision is taking place
 */
    public void CallOnCollisionStay(Collision collision, ref GruntState playerState, ref float playerAlpha)
    {
        m_collisionState = CollisionState.None;

        foreach (ContactPoint contact in collision)
        {
            Debug.DrawRay(contact.point, contact.normal);
            //
            if (contact.otherCollider != null && contact.otherCollider.gameObject != null)
            {
                CSceneObjectPlatform platform = contact.otherCollider.gameObject.GetComponent <CSceneObjectPlatform>();
                if (platform != null && m_platform == null)
                {
                    m_platform = platform;
                    m_platform.resetDeltaA();
                }
            }

            //
            CSceneObject obj = null;
            if (contact.otherCollider)
            {
                obj = contact.otherCollider.gameObject.GetComponent <CSceneObject>();
                if (obj == null && contact.otherCollider.gameObject.transform.parent != null)
                {
                    GameObject parent = contact.otherCollider.gameObject.transform.parent.gameObject;
                    if (parent != null)
                    {
                        obj = parent.GetComponent <CSceneObject>();
                    }
                }
            }

            // floor check
            else if (isNearly(contact.normal.y, 1.0f, 0.8f))
            {
                m_collisionState = CollisionState.OnFloor;
                if (!isNearly(contact.normal.y, 1.0f, 0.15f) && collision.contacts.Length == 1)
                {
                    if (m_grunt.GetGruntState() == GruntState.Walking)
                    {
                        if (m_grunt.GetGruntPlayerDetected())
                        {
                            m_velocity = (m_movingDirection * 0.6f);
                        }
                        else
                        {
                            m_velocity = (m_movingDirection * 0.15f);
                        }
                        m_velocityLockTimer = (Time.time * 1000.0f);
                    }
                }
                if (contact.otherCollider)
                {
                    // are we on a special material?
                    m_footMaterial = FootMaterial.Stone;
                    if (contact.otherCollider.tag == "Wood Object")
                    {
                        m_footMaterial = FootMaterial.Wood;
                    }
                    else if (contact.otherCollider.tag == "Metal Object")
                    {
                        m_footMaterial = FootMaterial.Metal;
                    }
                }
            }
            // head check
            else if (isNearly(contact.normal.y, -1.0f, 0.1f))
            {
                m_collisionState = CollisionState.OnRoof;
            }
            // wall check
            else
            {
                if (isFacingCollision(m_movingDirection, m_body.transform.position, contact.point, playerAlpha))
                {
                    m_collisionState = CollisionState.OnWall;
                    break;
                }
            }
        }

        if (m_collisionState == CollisionState.OnWall && m_jumpState == JumpState.Jumping && playerState != GruntState.WallJumpStart)
        {
            m_velocity = -(m_movingDirection * 0.15f);
        }

        if (m_collisionState == CollisionState.OnFloor && ((Time.time * 1000.0f) - m_jumpTimer > 200.0f))
        {
            m_jumpState = JumpState.Landed;

            if (m_grunt.GetGruntState() != GruntState.Turning)
            {
                m_grunt.SetGruntState(GruntState.Standing);
            }
        }
    }
示例#9
0
    /*
     * \brief Works out if a value is almost another value (for floating point accuracy)
     */
    public void CallOnCollisionEnter(Collision collision, bool playerDetected)
    {
        m_collisionState = CollisionState.None;

        foreach (ContactPoint contact in collision)
        {
            m_platform = contact.otherCollider.gameObject.GetComponent <CSceneObjectPlatform>();
            if (m_platform != null)
            {
                m_platform.resetDeltaA();
            }
            else if (isNearly(contact.normal.y, 1.0f, 0.2f))
            {
                m_collisionState = CollisionState.OnFloor;

                // are we on a special material?
                m_footMaterial = FootMaterial.Stone;
                if (contact.otherCollider.tag == "Wood Object")
                {
                    m_footMaterial = FootMaterial.Wood;
                }
                else if (contact.otherCollider.tag == "Metal Object")
                {
                    m_footMaterial = FootMaterial.Metal;
                }
            }
            else if (isNearly(contact.normal.y, -1.0f, 0.2f))
            {
                m_collisionState = CollisionState.OnRoof;
            }
            else
            {
                m_collisionState = CollisionState.OnWall;
            }
        }

        if (m_collisionState == CollisionState.OnFloor)
        {
            if (m_jumpState != JumpState.Landed)
            {
                m_grunt.GetPlayerAnimation().PlayFootstepAudio(m_footMaterial);
            }

            m_jumpState = JumpState.Landed;
        }
        if ((m_collisionState == CollisionState.OnWall || collision.collider.gameObject.name == "GruntBarrier") && m_grunt.GetGruntState() != GruntState.Turning && m_grunt.GetGruntState() != GruntState.Attacking)
        {
            if (!playerDetected)
            {
                m_grunt.SetGruntState(GruntState.Turning);
                if (m_movingDirection == 1)
                {
                    m_movingDirection = -1;
                    m_direction       = -1;
                }
                else if (m_movingDirection == -1)
                {
                    m_movingDirection = 1;
                    m_direction       = 1;
                }
            }
            else
            {
                m_grunt.SetGruntState(GruntState.Standing);
            }
        }
    }
    /*
     * \brief Called whilst a collision is taking place
    */
    public void CallOnCollisionStay(Collision collision, ref GruntState playerState, ref float playerAlpha)
    {
        m_collisionState = CollisionState.None;

        foreach (ContactPoint contact in collision)
        {
            Debug.DrawRay(contact.point, contact.normal);
            //
            if (contact.otherCollider != null && contact.otherCollider.gameObject != null)
            {
                CSceneObjectPlatform platform = contact.otherCollider.gameObject.GetComponent<CSceneObjectPlatform>();
                if (platform != null && m_platform == null) {
                    m_platform = platform;
                    m_platform.resetDeltaA();
                }
            }

            //
            CSceneObject obj = null;
            if (contact.otherCollider)
            {
                obj = contact.otherCollider.gameObject.GetComponent<CSceneObject>();
                if (obj == null && contact.otherCollider.gameObject.transform.parent != null) {
                    GameObject parent = contact.otherCollider.gameObject.transform.parent.gameObject;
                    if (parent != null) {
                        obj = parent.GetComponent<CSceneObject>();
                    }
                }
            }

            // floor check
            else if (isNearly(contact.normal.y, 1.0f, 0.8f))
            {
                m_collisionState = CollisionState.OnFloor;
                if (!isNearly(contact.normal.y, 1.0f, 0.15f) && collision.contacts.Length == 1)
                {
                    m_velocity = (m_movingDirection * 0.15f);
                    m_velocityLockTimer = (Time.time * 1000.0f);
                }
                if(contact.otherCollider)
                {
                    // are we on a special material?
                    m_footMaterial = FootMaterial.Stone;
                    if (contact.otherCollider.tag == "Wood Object")
                        m_footMaterial = FootMaterial.Wood;
                    else if (contact.otherCollider.tag == "Metal Object")
                        m_footMaterial = FootMaterial.Metal;
                }
            }
            // head check
            else if (isNearly(contact.normal.y, -1.0f, 0.1f))
            {
                m_collisionState = CollisionState.OnRoof;
            }
            // wall check
            else
            {
                if (isFacingCollision(m_movingDirection, m_body.transform.position, contact.point, playerAlpha)) {
                    m_collisionState = CollisionState.OnWall;
                    break;
                }
            }
        }

        if (m_collisionState == CollisionState.OnWall && m_jumpState == JumpState.Jumping && playerState != GruntState.WallJumpStart)
        {
            m_velocity = -(m_movingDirection * 0.15f);
        }

        if (m_collisionState == CollisionState.OnFloor && ((Time.time * 1000.0f) - m_jumpTimer > 200.0f))
        {
            m_jumpState = JumpState.Landed;

            if (m_grunt.GetGruntState() != GruntState.Turning) m_grunt.SetGruntState(GruntState.Standing);
        }
    }
    /*
     * \brief Works out if a value is almost another value (for floating point accuracy)
     */
    public void CallOnCollisionEnter(Collision collision)
    {
        m_collisionState = CollisionState.None;

        foreach (ContactPoint contact in collision)
        {
            m_platform = contact.otherCollider.gameObject.GetComponent <CSceneObjectPlatform>();
            if (m_platform != null)
            {
                m_platform.resetDeltaA();
            }
            if (isNearly(contact.normal.y, 1.0f, 0.2f))
            {
                m_collisionState = CollisionState.OnFloor;

                if (m_player.GetPlayerState() == PlayerState.OnLadder)
                {
                    GetLadder.state = LadderState.AtBase;
                    m_player.SetPlayerState(PlayerState.Standing);
                }

                // are we on a special material?
                m_footMaterial = FootMaterial.Stone;
                if (contact.otherCollider.tag == "Wood Object")
                {
                    m_footMaterial = FootMaterial.Wood;
                }
                else if (contact.otherCollider.tag == "Metal Object")
                {
                    m_footMaterial = FootMaterial.Metal;
                }
            }
            else if (isNearly(contact.normal.y, -1.0f, 0.2f))
            {
                m_collisionState = CollisionState.OnRoof;
                if (contact.otherCollider != null && contact.otherCollider.GetComponent <CSceneObjectPlatform>() != null)
                {
                    m_player.PushPlayerFromTower();
                }
            }
            else
            {
                if (m_player.GetPlayerState() != PlayerState.OnLadder)
                {
                    m_collisionState = CollisionState.OnWall;
                }
            }
        }

        if (m_collisionState == CollisionState.OnFloor)
        {
            if (m_jumpState != JumpState.Landed)
            {
                m_player.GetPlayerAnimation().PlayFootstepAudio(m_footMaterial);
            }

            m_jumpState = JumpState.Landed;

            if (GetLadder.state == LadderState.JumpingOff)
            {
                GetLadder.state = LadderState.None;
            }

            if (m_player.GetPlayerState() != PlayerState.Turning && m_player.GetPlayerState() != PlayerState.OnLadder && !m_player.PullingLever(false))
            {
                m_player.SetPlayerState(PlayerState.Standing);
            }
        }
    }
    /*
     * \brief Works out if a value is almost another value (for floating point accuracy)
    */
    public void CallOnCollisionEnter(Collision collision, bool playerDetected)
    {
        m_collisionState = CollisionState.None;

        foreach (ContactPoint contact in collision)
        {
            m_platform = contact.otherCollider.gameObject.GetComponent<CSceneObjectPlatform>();
            if (m_platform != null) {
                m_platform.resetDeltaA();
            }
            else if (isNearly(contact.normal.y, 1.0f, 0.2f))
            {
                m_collisionState = CollisionState.OnFloor;

                // are we on a special material?
                m_footMaterial = FootMaterial.Stone;
                if (contact.otherCollider.tag == "Wood Object")
                    m_footMaterial = FootMaterial.Wood;
                else if (contact.otherCollider.tag == "Metal Object")
                    m_footMaterial = FootMaterial.Metal;

            }
            else if (isNearly(contact.normal.y, -1.0f, 0.2f))
            {
                m_collisionState = CollisionState.OnRoof;
            }
            else
            {
                m_collisionState = CollisionState.OnWall;
            }
        }

        if (m_collisionState == CollisionState.OnFloor)
        {
            if (m_jumpState != JumpState.Landed)
                m_grunt.GetPlayerAnimation().PlayFootstepAudio(m_footMaterial);

            m_jumpState = JumpState.Landed;
        }
        if ( (m_collisionState == CollisionState.OnWall || collision.collider.gameObject.name=="GruntBarrier") &&  m_grunt.GetGruntState() != GruntState.Turning && m_grunt.GetGruntState() != GruntState.Attacking)
        {
            if( !playerDetected )
            {
                m_grunt.SetGruntState( GruntState.Turning );
                if( m_movingDirection == 1)
                {
                    m_movingDirection = -1;
                    m_direction = -1;
                }
                else if( m_movingDirection == -1 )
                {
                    m_movingDirection = 1;
                    m_direction = 1;
                }
            }
            else
            {
                m_grunt.SetGruntState( GruntState.Standing );
            }
        }
    }