How do I stop animations of objects out of the frame ?

0 favourites
  • 7 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • Hello, I'm trying to stop the animation of instances of objects as soon as they aren't on screen.

    So, I made this event :

    (I wrote the translation on this screenshot 'cause otherwise it's in french)

    When I check the animations (in the debug console) of instances which are out of the screen, they don't play their animation, so for them it's OK.

    BUT the instances which are on screen don't play their animation as well ! And if I go towards another instance to have it on screen, same issue : no animation.

    Is my event wrong ?

  • Kind of.

    Your event Blocking_Props are on screen is executed every ticks.

    So every ticks, you are setting your animation to play from the starting frame.

    So you never give time to your animation to actually naturally play.

    Try adding the system condition "Trigger once while true".

    This way, the animation would be set only once, and would then play, until the instance goes out of screen.

    "Blocking_Props is NOT playing animation" and the name of the animation it is supposed to be playing, could be another way to achieve the same thing.

  • Thank you for your answer Kyatric.

    I tried this :

    The boolean LevelStarting is true by default and after some time, it is deactivated. And it's true that thanks to this, the animations of the blocking_props instances are playing since the first frame. Then, instances which are not on the screen are stopping their animation, great !

    But as soon as another instance is on the screen, this instance doesn't play its animation, only the first one is playing.

    On this screenshot, the first terrarium is playing its animation but not the second one. The third one is out of the screen so it's not playing the animation, it's OK for this one.

    And something that I don't understand is that on the second terrarium, you can notice that "is playing" is "true" ("vrai" in french, sorry I forgot to translate it on the screenshot) but in fact it is not the case, the animation is not playing.

    I tried to go to the third instance on the right and it's not playing its animation neither as long as there is more than one instance on the screen. As soon as there is only one instance, this instance is playing its animation.

    I hope I was clear here. :)

  • Consider posting your project and providing steps to reproduce the issue.

    It will be simpler to diagnose and help.

    And as mentioned in my previous answer, it is possible to use a different condition from the Sprite object (Animation is playing) instead of the System Trigger only once.

    You might also try to remove the original "for each instance" loop and use directly the "is on screen"/"is NOT on screen" condition as top level event, since they are automatically looping through instances already.

  • OK, I reproduced the issue in a simple project file, tje problem is exactly the same I have in my game. Here is the link.

    Thanks again Kyatric ! :)

  • Why do you want to stop animations for off-screen objects? If you think this will improve performance, it probably won't. These events executed on every tick will likely have the same performance impact (or even worse), as playing animations.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Add a boolean "animPlay" instance variable to your "object", false by default.

    Set your events :

    As indicated previously, no need for the "For each" event, the instances are automatically looped through.

    The condition "Is 'anim' playing" is in fact true, because it is playing 'anim', whether the animation is actually playing or not.

    So handle knowing if your sprite is playing or not using the boolean instance 'animPlay'.

    Doing so, everything works as intended as far as I can tell.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)