Good way to toggle movements on or off (optimization help)

Get help using Construct 2

Post » Sat Dec 10, 2016 11:55 am

I'm trying to make my game run better on less powerful systems and would love to hear some tips on how to approach this.

I have multiple objects / enemies with mostly simple movement behaviors (sine, LiteTween) that I would like to toggle off when player character is not in their immediate vicinity. Then when player is near them, I'd like to toggle the movement back on (and of course make all this work so that player never notices any difference .. except hopefully better framerate:).

I tried using "is on-screen" / "not on-screen" in events for this and it works somewhat, but not exactly as I'd like. If the object / enemy is right outside the screen (but still very near) it also stops moving and never comes to view again unless player moves, and I would like to find a better solution to this.

Ideas that come to mind are using something like line of sight, checking for distance between player and the object(s) or using invisible detector sprite pinned to the player to check for overlap with enemy objects and activating when overlapping. However, I don't really have any idea on how much of a performance hit each of these methods are and what is the best approach to try.

I'd like to improve the performance instead of making it worse, so would love to hear ideas on efficient ways to do this. Thanks for any help!
B
31
S
9
G
4
Posts: 131
Reputation: 4,321

Post » Sat Dec 10, 2016 7:32 pm

If you want to make something happen based on distance, you can actually use distance(1.X, 1,Y, 2.X, 2.Y) Replace the numbers with the names of your variables. I hope that helped. I'm still pretty new.
B
8
S
3
G
3
Posts: 13
Reputation: 2,130


Return to How do I....?

Who is online

Users browsing this forum: Rudi55 and 5 guests