Beispiel #1
0
    void Update()
    {
        DirectionMov = Vector3.zero;
        if (Input.GetMouseButton(0))
        {
            targetPos = IO_Mouse.MouseWorldPosition(transform.position, mask);
        }

        if (!IsFlying)
        {
            DirectionMov = AI_Steering.Seek(transform.position, targetPos, SeekForce, Range, curve);
        }
        else
        {
            DirectionMov = AI_Steering.SeekFlying(transform.position, targetPos, SeekForce, Range, curve);
        }

        //Avatar visuals
        var speed = Mathf.Min(RB.velocity.sqrMagnitude / MAXSPEED, 1.0f);

        if (speed > 0.1f)
        {
            anim.SetFloat("IsMoving", 1.0f);
            CalculateRotation();
        }
        else
        {
            anim.SetFloat("IsMoving", 0.0f);
        }

        anim.SetFloat("Speed", speed);
    }
    void Update()
    {
        DirectionMov = Vector3.zero;

        if (Target)
        {
            targetPos = Target.position;
        }
        else
        {
            targetPos = IO_Mouse.MouseWorldPosition(transform.position, mask);
        }

        if (!IsFlying)
        {
            DirectionMov  = AI_Steering.Seek(transform.position, targetPos, SeekForce, Range, curve);
            DirectionMov += AI_Steering.Flee(transform.position, targetPos, FleeForce, Range, curve);
        }
        else
        {
            DirectionMov  = AI_Steering.SeekFlying(transform.position, targetPos, SeekForce, Range, curve);
            DirectionMov += AI_Steering.FleeFlying(transform.position, targetPos, FleeForce, Range, curve);
        }

        //Rotation
        if (DirectionMov.sqrMagnitude > 0f)
        {
            avatar.forward = DirectionMov;
        }
    }
 void Update()
 {
     directionMove = Vector3.zero;
     if (Input.GetMouseButton(0))
     {
         Vector3 targetPos = IO_Mouse.MouseWorldPosition(transform.position, mask);
         directionMove = AI_Steering.SeekFlying(transform.position, targetPos, Speed);
     }
 }