1
$\begingroup$

I was trying to figure out how to add a delay to my BGE game so that it has a cooldown, like when using something.

The only solution I found is this: if you click the button at the exact same tic every 60 tics it will work but not other tics.

$\endgroup$

1 Answer 1

0
$\begingroup$

There are a few ways of creating a delay. I have two* different ways below.

A timer game property

One simple way is to use a timer property, and reset the timer each time our event is triggered.
I have a game property named "timer" and it is a timer type of property.

logic bricks

The Keyboard sensor and Action actuator are just so my object does something. You only need to add a Property sensor and a Property actuator.

The Property actuator needs to be set to assign a value of zero, this is how the timer gets reset.

Now the Property sensor checks to see if the timer is greater then 1.5 seconds, when it is it will send a True plus to the And controller. If it is not then you will not be able to trigger your action until the timer counts high enough.


A timer game property v2

In this screen shot the logic bricks do the exact same thing as the ones above, but here the And controller is switched out for an Expression controller.
logic bricks with an expression

The expression timer >=1.5 checks if the game property "timer" is greater then or equal to 1.5; doing it this way there is no need for the Property sensor.


* It is the exact same method, just with sightly different logic bricks.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .