How to reset behavior after rewinding

Alex Vemon 3 years ago updated by Lazlo Bonin (Lead Developer) 3 years ago 2
Hi, I was wondering if someone can point me into the right direction.

I have a turret enemy, it doesn’t move but it fires projectiles within a certain radius.
If it shoots and I rewind time, the projectiles go back to the turret and they disappear as they should.
But if I keep rewinding time after the projectiles disappear it includes time when the turret was “idle”.
So when I move time forward it won’t shoot me right away even if im within the attack radius until the time I rewound is covered when moving time forward.

Is there anyway I can make it so it ignores that idle time and resumes its normal behavior right after I move time forward? Repeatable is set to false.

Here is the code:

 public override void CheckDistance()

        if (Vector3.Distance(target.position, transform.position) <= chaseRadius && 
        Vector3.Distance(target.position, transform.position) > attackRadius)

            if (currentState == EnemyState.idle || currentState == EnemyState.walk && 
            currentState != EnemyState.stagger)
                if (canFire)

                    if (time.timeScale > 0)
                        false, //not Repeatable

                        delegate () // On forward
                            anim.SetBool("wakeUp", true);
                            Vector3 tempVector = target.transform.position - transform.position;
                            GameObject current = Instantiate(projectile, transform.position, Quaternion.identity);
                            return current;

                        delegate (GameObject current) // On backward

                        fireDelaySeconds = fireDelay;
                        canFire = false;




Chronos Version:
Unity Version:

This is a Chronos question , why was it moved to bolt?


Hi Alex, sorry for the confusion, moved to the right forum.

Chronos timelines are always continuous, so you can't "skip" an idle part unfortunately.

What you could do is set the time scale of that turret to zero once it reaches the idle state (instead of -1). This way, it will actually hold at the exact moment where it would start firing again.

Hope that helps!