At the beginning of the scene, Ghost’s Random Time Variable will set to Random in Range 4 to 6 which determines when the Ghost’s will teleport. It works fine with only one object present but when there’s multiple Ghost’s object in the field only one teleports. The problem is this, If I put two or more Ghost object, For ex. Ghost 1 will teleport in 4 sec. and Ghost to is 5 sec. The Ghost 1 will teleport first and the timer will reset and the other Ghost will not able to teleport because the timer was already resets. I try to put for each object on the part where it resets but it doesn’t work. I just want a the Ghosts to have different time to teleport and chase.
I try to put it above all the events of ghost but it didn’t work as well as putting for each object below the EnemyGhostVariable + 3 but it doesn’t work too.
Can you help with it? I try it but it doesn’t work. I think I’m missing something here.
Here’s the project: PR - Google Drive
I put comments on the events that needs to fix. Those events works perfectly on the object when I put only one but when I put two or more, problem comes.
Please help me fix the Ghost object as well as the Ram.
Ghost: Chases the Player and when the Timer is greater than the Random Variable, It Teleports to another random location then repeat.
Ram: Moves slowly and in random direction and when the Timer is greater than the Random Variable, It dashes to the current location of the Player then it needs to stop when collided to a wall then repeat.
You can put first 1 Ghost and Ram to see what results I’ve been looking for. The goal is just to make it work also in 2 or more of each object. Thanks in advance!
I’ve tested it and unfortunately it’s the same than before. I’ve found out that the major problem is the time reset.
For example, there where 2 Ghosts then they’ve got different variable for the timer.
Ghost #1 got “3” which means he will do the teleport action if the timer is greater than “3”
Ghost #2 got “5” which means he will do the teleport action if the timer is greater than “5”
The problem is that when Ghost #1 finished the teleport, it will soon resets the timer and that’s why Ghost #2 will never do the teleport thing because the timer was already resets.
It seems like even if you put “for each object of Ghost”, the timer of all Ghosts will reset if one Ghost manage to reach the condition first. This is also the problem to the Ram and my other enemies. Is there a way to make every Ghosts have individual timers that will reset for only a specific Ghost and not all of them.
Note: Sometimes, these two ghosts disappear at the same time and that’s because you haven’t given much space for getting random number. There is only maximum 2 second disappearing time difference so sometimes, the Random numbers can be same.
LOL, I totally forgot to identify each ghost with a different timer, I’m going to update the project and reupload.
Here every ghost will have an UID to identify and added to the timer name os the timers are different for each ghost like “Transport0”, “Transport1”, and so on https://drive.google.com/file/d/10pDw1ApRaS_C14NiV0ozlm1TGcJdE8ap/view?usp=sharing
Thank you so much! @UlisesFreitas and @Muzan! That’s what I didn’t know! I’m sorry for having a lot of problems I only knew the basics of GDevelop. Thanks for helping out!
So I’ve tested out @UlisesFreitas file and it’s not working again and I don’t why. I’ve tried @Muzan file and it works I guess but I don’t know what you’ve did because the only thing I see there is this:
and the others are in the cancel thing (I don’t know what to call it) Can you explain me how does it work?
My goal is to have every Ghost have 4 to 6 in timer randomly and do the events if they reach it individually. For ex:
Ghost #1 (4) 1 2 3 reset then got 5 → 1 2 3 4 reset then got 5 → 1 2 3 4 reset and so on…
Ghost #2 (5) 1 2 3 4 reset then got 6 → 1 2 3 4 5 reset then got 4 → 1 2 3 reset and so on…
Ghost #3 (6) 1 2 3 4 5 reset then 4 → 1 2 3 reset then got 6 → 1 2 3 4 5 reset and so on…
“then got” means they get a new random timer. I tested out @UlisesFreitas file but when the I counted before they do the events, only one Ghost do it and I wait until 6 seconds because that’s the limit of each Ghosts before they do the events, the other Ghosts didn’t do it. But in @Muzan file it looks like what I want but I didn’t know if it’s 4 to 6 timer just like I presented.
Can I call objects specifically in creating events with this function behavior? I want to call out the Player’s X and Y position because that’s what I want to be the target because this enemy is a Ram. If not, how can I input it? Like when I want events with collision to another object? How can I specify what object I want?
Edit: I think I got it now. So, you want Player.X() and Player.Y(). You can’t do that. You can only call objects with the doStepPreEvent and doStepPostEvent and a Custom function.
Maybe you can create a Custom Action function, call Player.X() and Player.Y() from there and do that action at the beginning of the scene or while creating your Enemy, in your Scene Events.