Example #1
0
    public void Tick(float deltaTime)
    {
        if (timeStep < MIN_TIMESTEP)
        {
            timeStep = MIN_TIMESTEP;
        }

        pawn.EarlyTick(deltaTime);

        if (running)
        {
            remainingTime += deltaTime * timeScale;
        }

        while (remainingTime > timeStep)
        {
            FixedTick(timeStep);
            remainingTime -= timeStep;
        }

        pawn.LateTick(deltaTime);
        enemy.LateTick(deltaTime);

        ABDraw.BatchDraw();

        if (Input.GetKeyDown(KeyCode.F1))
        {
            drawDebug = !drawDebug;
        }
    }
Example #2
0
 public void FixedTick(float deltaTime)
 {
     ABDraw.TickLines(deltaTime);
     Physics.SyncTransforms();
     pawn.FixedTick(deltaTime);
     enemy.FixedTick(deltaTime);
 }
Example #3
0
    public void FixedTick(float deltaTime)
    {
        float3 direction = transform.forward;
        float  distance  = speed * deltaTime;

        RaycastHit hit;
        float3     deltaPos;
        Color      lineColor = Color.white;

        if (Physics.SphereCast(physicPosition, coll.radius, direction, out hit, distance))
        {
            deltaPos  = direction * (hit.distance - 0.01f);
            lineColor = Color.red;
        }
        else
        {
            deltaPos = direction * distance;
        }

        physicPosition += deltaPos;

        float3 start = physicPosition + float3(transform.forward) * coll.radius;
        float3 end   = start + deltaPos;

        ABDraw.Line(start, end, lineColor);


        currentLifetime += deltaTime;
        if (currentLifetime > lifetime)
        {
            dead = true;
        }
    }