0 Favourites

Enemy movement in System.Tick?

  • I've got some enemy sprites which are moving around by using Platform behavior and simulating the left and right key presses.

    However, I realized in the event editor I can use either:

    On System.Tick

    if(Zombie instance var 'facing' = "left") simulate keypress left

    if(Zombie instance var 'facing' = "right") simulate keypress right

    or I can simply do a 'Compare instance variable' event:

    On (Zombie instance var 'facing' = "left") simulate keypress left

    On (Zombie instance var 'facing' = "right") simulate keypress right

    Can anyone outline the difference between these from a performance perspective? Which one would you recommend?

    Thanks,

    -- cacotigon

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Not sure if there's a performance hit.

    I think it is more about the "elegance" of the event sheet.

    Moreover, the "every tick" is a bit redundant, as the "Compare instance variable" is ran every tick anyway in that case (top level event, no other filtering).

    I think in the end it's better for readability to not use "every tick" there but I couldn't swear it will have an impact on performances.

  • Forget about performance on individual events like that - it's a waste of time. Rendering a sprite will probably take 100 times as long as whatever difference there is, so it basically doesn't matter at all.

    I'd recommend using conditions in the object instead of conditions from "system" wherever possible, because events generally work better that way (not because of the performance).

  • okay, thanks, that clears it up for me. I see what you're saying Kyatric, organizing events which pertain to a object through that object's conditions in the event sheet helps with readability/maintainability. Thanks Ashley about trying to use less System events.

    Back to coding!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
233 22,268
TiAm's avatar
TiAm
Unread hot topic
0 Favourites
Path Movement Behavior
98 52,480
R0J0hound's avatar
R0J0hound
Unread hot topic
48 6,875
DUTOIT's avatar
DUTOIT