// Update is called once per frame
    void Update()
    {
        path.draw();

        if (reversePath && isAtEndOfPath())
        {
            path.reversePath();
        }

        Vector3 accel = followPath.getSteering(path, pathLoop);

        steeringBasics.steer(accel);
        steeringBasics.lookWhereYoureGoing();
    }
Esempio n. 2
0
    void Update()
    {
        path.draw();

        // 执行原路返回的逻辑
        if (reversePath && isAtEndOfPath())
        {
            path.reversePath();
        }

        // 计算线性加速度
        Vector3 accel = followPath.getSteering(path, pathLoop);

        // 设置刚体速度
        steeringBasics.Steer(accel);
        // 朝向
        steeringBasics.LookWhereYoureGoing();
    }
Esempio n. 3
0
    void FixedUpdate()
    {
        if (followPath.isAtEndOfPath(path))
        {
            path.reversePath();
        }

        Vector3 accel = wallAvoidance.getSteering();

        if (accel.magnitude < 0.005f)
        {
            accel = followPath.getSteering(path);
        }

        steeringBasics.steer(accel);
        steeringBasics.lookWhereYoureGoing();

        path.draw();
    }
    // Update is called once per frame
    void Update()
    {
        path.draw();

        if (isAtEndOfPath())
        {
            path.reversePath();
        }

        Vector2 accel = colAvoid.getSteering(colAvoidSensor.targets);

        if (accel.magnitude < 0.005f)
        {
            accel = followPath.getSteering(path);
        }

        steeringBasics.steer(accel);
        steeringBasics.lookWhereYoureGoing();
    }
Esempio n. 5
0
    private void Update()
    {
        // 到达终点了, 原路返回
        if (IsAtEndOfPath())
        {
            path.reversePath();
        }

        // 得到加速度 (要躲避墙)
        Vector3 accel = wallAvoidance2.GetSteering();

        // 沿着路径走了 (约定没有碰撞时, 加速度为0 了)
        if (accel.magnitude < 0.005f)
        {
            accel = followPath.getSteering(path);
        }

        // 设置刚体 和 朝向
        steeringBasics2.Steer(accel);
        steeringBasics2.LookWhereYoureGoing();

        // 调试
        path.draw();
    }
Esempio n. 6
0
    void Update()
    {
        // 调试
        path.draw();

        // 是否原路返回
        if (isAtEndOfPath())
        {
            path.reversePath();
        }

        // 躲避 加速度
        Vector3 accel = colAvoid.GetSteering(colAvoidSensor.targets);

        // 不需要躲避 就沿着路径走
        if (accel.magnitude < 0.005f)
        {
            accel = followPath.getSteering(path);
        }

        // 设置刚体速度 和 朝向
        steeringBasics.Steer(accel);
        steeringBasics.LookWhereYoureGoing();
    }