public override State LerpState(State from, State to, float value)
        {
            RectState fromState = null;
            var       toState   = (RectState)to;

            if (from != null)
            {
                fromState = (RectState)from;
            }
            else
            {
                fromState = this.currentState;
            }

            if ((this.parameters & AnimationParameter.Position) != 0)
            {
                this.currentState.anchorPosition = Vector2.Lerp(fromState.anchorPosition, toState.anchorPosition, value);
            }
            if ((this.parameters & AnimationParameter.Rotation) != 0)
            {
                this.currentState.rotation = Vector3.Slerp(fromState.rotation, toState.rotation, value);
            }
            if ((this.parameters & AnimationParameter.Scale) != 0)
            {
                this.currentState.scale = Vector3.Lerp(fromState.scale, toState.scale, value);
            }

            return(this.currentState);
        }
Exemplo n.º 2
0
    public override void Initialize()
    {
        // f**k you mlagents team
        m_ExistentialReward  = 1f / 1000000f;
        m_OutOfBoundsReward  = 1f / 10000f;
        totalHitReward       = 0f;
        m_HitReward          = 0.05f;
        m_BehaviorParameters = gameObject.GetComponent <BehaviorParameters>();
        if (m_BehaviorParameters.TeamId == (int)RectTeam.Blue)
        {
            team        = RectTeam.Blue;
            m_Transform = new Vector3(transform.position.x, 1f, transform.position.z);
        }
        else
        {
            team        = RectTeam.Yellow;
            m_Transform = new Vector3(transform.position.x, 1f, transform.position.z);
        }

        m_LateralSpeed             = 2.0f;
        m_ForwardSpeed             = 2.0f;
        m_Settings                 = FindObjectOfType <RectSettings>();
        agentRb                    = GetComponent <Rigidbody>();
        agentRb.maxAngularVelocity = 500;

        var playerState = new RectState
        {
            agentRb     = agentRb,
            startingPos = transform.position,
            agentScript = this,
        };

        area.playerStates.Add(playerState);
        m_PlayerIndex           = area.playerStates.IndexOf(playerState);
        playerState.playerIndex = m_PlayerIndex;

        m_ResetParams = Academy.Instance.EnvironmentParameters;
    }