Attention |
Topic was automatically imported from the old Question2Answer platform. | |

Asked By |
chantunRey |

I have a simple timer and it runs twice on the process function.

```
var days = 0
var dayTime = 0
func _physics_process(delta):
dayTimer(delta)
func dayTimer(delta):
dayTime += delta
if dayTime > 3:
days += 1
print("day: " + str(days))
weHaveChild()
dayTime = 0
func weHaveChild():
var partners = floor(adults/2)
for i in partners:
var chance = randi()%100+1
if chance <= 5:
self.add_child(child_born.new())
print("Nacio un pibe")
print("hay " + str(partners) + " parejas")
print("con chance de " + str(chance))
```

The dayTimer() function runs twice.

thanks

I’m not sure what you mean by “runs twice”. What do you expect this to do? Since the `_physics_process()`

function is called once for each physics frame, your `dayTimer()`

function will be called once per physics frame also…

jgodfrey | 2022-12-26 19:03

it should print

“day: 1

hay 1 parejas

con chance de 9

day: 2

hay 1 parejas

con chance de 9”

instead I get:

“day: 1

hay 1 parejas

con chance de 9

day: 1

hay 1 parejas

con chance de 35

day: 2

hay 1 parejas

con chance de 9

day: 2

hay 1 parejas

con chance de 83”

chantunRey | 2022-12-26 19:25