Delete instance after timeline has finished

0 favourites
  • 6 posts
  • I'm trying to do something quite simple with the timeline; animate a tool that the player is swinging.

    When the player presses a button, I'm creating an instance of this tool. After the tool has swung, I would like to simply delete the instance.

    I managed to add the rotation animation for the tool using the timeline. I'm using "set instance" to schedule the freshly created tool instance to play in the timeline. But how can I select the instance that has just finished playing it's timeline animation for destruction? Is there some obvious way of selecting instances involved in a timeline animation that I'm missing?

    Thank you!

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey man. Maybe you could create a variable inside the object called something like "endReached". In the timeline, use or create a masterkey near the end (not exactly in the end) of the animation tagged as "end".

    In the Event Sheet, using the "master key frame reached" event (don't remember if that's the name, I use it in other language), put the "end" tag in the available option.

    As an action, set the endReached variable to 1.

    Then create a last event/action "if endReached == 1, destroy gameObject".

    Don't know if it could work, but it's an idea. Good luck!

  • If the instance of the tool is always the most recent instance of that object then you can use this to destroy it after the timeline finishes.

    Just replace the Characters object with your object.

  • Hi!

    Thanks for helping!

    Luckily I got it to work quite simply in the end, I just used a "system" --> "wait for previous actions to complete" action after starting the timeline and then I destroyed the instance, all in the same event block.

  • Thanks calminthenight, we posted almost at the same moment!

    Unfortunately there might be a newer instance that exists at the same time since I'm allowing the player to swing with every button press (so two rapid button presses might actually create two instances).

  • Hi!

    Thanks for helping!

    Luckily I got it to work quite simply in the end, I just used a "system" --> "wait for previous actions to complete" action after starting the timeline and then I destroyed the instance, all in the same event block.

    Good idea! =D

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