Enemy movement in System.Tick?

0 favourites
  • 4 posts
From the Asset Store
Be discreet and rescue your friends from behind enemy lines.
  • 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

  • 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).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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)