we had similiar with button press in other Topic, here is zthe copy paste.
Iam sure you can convert it to your needs, it shows good the use of switch to solve your problem.
if button press
if switch1 is off
do change grafic and stuff
turn switch 1 on
else nothing
else
if switch1 is on
change grafic back to normal
turn switch 1 off.
thisway the change grafic is just executed one time when needed. Changing Actor Grafic every frame is one of the stuffs that burns/uses most of the performance reserves. Maybe this helps, if you do something else and this is not needed, than just ignore it 🙂 .
you can't trigger it any other way.
You need to use a wait command at the end of that CE to have it skip a number of frames.
The exact number you need to test by experimentation - too high and there may be a delay in the actor change, too low and you get lag.
Something between 10 and 30 should be OK
EDIT:
@Bex: he isn't changing by button but by region code, and he already has a switch as trigger so no need for conditional branches
@Andar, dont know what you mean, but i write it down for region than, you may right that that is better understandable for others.
Your wait stuff not realy solves the problem.Its not wrong but also not the whole answer in my opinion.
if Variable19 = 1
if switch1 is off
do change grafic and stuff
turn switch 1 on
no else case for seccond branch
else (of first branch)
if switch1 is on
change grafic back to normal
turn switch 1 off.
end
Edit: Wait 4 or more Frames (Optional) (your lag problem was the change grafic command with every iteration)
thisway the change grafic is just executed one time when needed. Changing Actor Grafic every frame is one of the stuffs that burns/uses most of the performance reserves.This is what op means with endless loop even if its not a real endless loop that freezes game.
I have 1 Paralell Event that checks for example:
200 Conditional Branches about Switches every frame, and it has no impact on performance.
but
I have 1 Paralell Event that does for example:
Change the Actor Grafic every frame, my Game will lag like Hell.
So OP must understand that checking something every frame is no problemwith switches or variables.
But your solution with wait command would help realy realy big projects to get some performance back.
My button press i needed every frame, but this swimm grafic change should be enough every 8 to 30 frames like andar said.
Only using the wait maybe helps also but it doesnt teach op how to event it properly. but without you i would had forgot to tell him about wait^^
Thank you guys, really appreciate the support!
I decided to just surround the whole ocean with events, outer layer to set the no-swimming graphic and inner layer to set a swimming graphic. Seems to work best this way, without much performance loss.
Thats also a possible and good and quick way for not to big maps. totally forgot the easiest solution ^^.