Exemplo n.º 1
0
    private void Drag(bool criticalLine = true)
    {
        Vector3 dragForward = MousePointInWorld() - transform.position;

        if (useController)
        {
            dragForward = cursor.GetComponent <ControllerSeek>().forward;
        }

        if (directVelocity)
        {
            mover.Move(dragForward, mover.maxSpeed, true);
        }
        else
        {
            mover.Accelerate(dragForward);
        }
        if (tracer != null)
        {
            tracer.AddVertex(transform.position);
        }
    }
Exemplo n.º 2
0
    void Update()
    {
        partnerWeight = Mathf.Clamp(partnerWeight, 0, 1);

        if (partnerLink.Partner != null)
        {
            if (tracer != null && !startedLine)
            {
                tracer.StartLine();
                startedLine = true;
            }

            if (partnerLink.Leading)
            {
                Vector3 destination = FindSeekingPoint((waypoints[current].transform.position - transform.position) * mover.maxSpeed);

                Vector3 fromPartner = transform.position - partnerLink.Partner.transform.position;
                fromPartner.z = 0;
                Vector3 fromPast = destination - transform.position;
                fromPast.z = 0;

                if (partnerWeight > 0 && Vector3.Dot(fromPartner, fromPast) <= 0)
                {
                    Vector3 waveFollowChange = fromPast * (1 - partnerWeight);

                    Vector3 considerPartnerChange = fromPartner.normalized * mover.maxSpeed * partnerWeight * Time.deltaTime;
                    destination = transform.position + waveFollowChange + considerPartnerChange;
                }

                mover.Accelerate(destination - transform.position);

                if (tracer != null)
                {
                    tracer.AddVertex(transform.position);
                }
            }
            else
            {
                mover.Accelerate(partnerLink.Partner.transform.position - transform.position);
                if (tracer != null)
                {
                    tracer.AddVertex(transform.position);
                }
            }
        }
        else if (moveWithoutPartner)
        {
            if (tracer != null && !startedLine)
            {
                tracer.StartLine();
                startedLine = true;
            }
            Vector3 destination = FindSeekingPoint((waypoints[current].transform.position - transform.position) * mover.maxSpeed);
            mover.Accelerate(destination - transform.position);
            mover.Accelerate(destination - transform.position);
            if (tracer != null)
            {
                tracer.AddVertex(transform.position);
            }
        }
        else
        {
            mover.SlowDown();
            if (tracer)
            {
                tracer.DestroyLine();
                startedLine = false;
            }
        }
    }