Beispiel #1
0
    public bool MoveToPoint(Vector3 point)
    {
        point.y = unit.thisT.position.y;

        float dist = Vector3.Distance(point, unit.thisT.position);

        if (dist < 0.15f)
        {
            //if the unit have reached the point specified
            return(true);
        }

        Quaternion wantedRot = Quaternion.LookRotation(point - unit.thisT.position);

        unit.thisT.rotation = Quaternion.Slerp(unit.thisT.rotation, wantedRot, 10 * Time.deltaTime);

        Vector3 dir = (point - unit.thisT.position).normalized;

        unit.thisT.Translate(dir * Mathf.Min(dist, dashFactor * unit.GetDefaultMoveSpeed() * Time.deltaTime * unit.GetSlowModifier()), Space.World);

        return(false);
    }