コード例 #1
0
    public override void DoAction(BasicAgent owner, float[] vectorAction)
    {
        var rBody = owner.GetComponent <Rigidbody>();
        var scale = owner.gameObject.transform.localScale.x;

        //rBody.angularVelocity = Vector3.zero;
        //rBody.velocity = Vector3.zero;
        //if (animator.GetInteger("AnimIndex") != 0)
        //{
        //    animator.SetInteger("AnimIndex", 0);
        //    animator.SetTrigger("Next");
        //}

        if (rBody is object)
        {
            Vector3 controlSignal = Vector3.zero;
            controlSignal.x = vectorAction[0];
            controlSignal.z = vectorAction[1];

            rBody.AddForce(new Vector3(controlSignal.x * owner.acceleration * scale, 0, controlSignal.z * owner.acceleration * scale));
        }

        SetDirection(owner);
        _lastPosition = owner.transform.position;

        IsFinished = true;
    }
コード例 #2
0
    public override void OnEnter(BasicAgent owner)
    {
        IsFinished = false;
        var rBody = owner.GetComponent <Rigidbody>();

        if (rBody is object)
        {
            rBody.angularVelocity = Vector3.zero;
            rBody.velocity        = Vector3.zero;
        }
        IsFinished = true;
    }