Couldn’t create a separate function for each instance

Not favoritedFavorited Favorited 0 favourites
  • 6 posts
From the Asset Store
_________ Infinite ribbon creation kit ___________
  • The function I want is:

    - The player will create a machine gun.

    - Each machine gun will have a duration (lifetime) when it’s created.

    - The machine gun should be destroyed when its time is over.

    I couldn’t create a separate function for each instance. When I spawn only one machine gun, it works fine. But if I spawn more than one, it doesn’t work as expected.

    Video showing the functionality I need: webmshare.com/play/dGjGx

    Events for creating: i.vgy.me/jDLomT.png

    Event for destroying: i.vgy.me/cM1COn.png

    Video showing the error: webmshare.com/play/VbLbj

  • I've explained this so many times in many posts, but people keep making the same two mistakes:

    1. You should never use Trigger Once condition with objects that have multiple instances. Trigger Once doesn't work per instance!
    2. You have events that run on every tick with Wait action in them. This creates lots of delayed threads, which will continue running for several seconds. Never use "wait" in events that run on every tick! It will break the game logic.

    Instead of "Trigger once" use some condition like "is pinned" or "turret enabled". Instead of "Wait" use the Timer behavior to destroy guns.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I've explained this so many times in many posts, but people keep making the same two mistakes:

    1. You should never use Trigger Once condition with objects that have multiple instances. Trigger Once doesn't work per instance!
    2. You have events that run on every tick with Wait action in them. This creates lots of delayed threads, which will continue running for several seconds. Never use "wait" in events that run on every tick! It will break the game logic.

    Instead of "Trigger once" use some condition like "is pinned" or "turret enabled". Instead of "Wait" use the Timer behavior to destroy guns.

    Thank you for the help

  • I've explained this so many times in many posts, but people keep making the same two mistakes:

    1. You should never use Trigger Once condition with objects that have multiple instances. Trigger Once doesn't work per instance!
    2. You have events that run on every tick with Wait action in them. This creates lots of delayed threads, which will continue running for several seconds. Never use "wait" in events that run on every tick! It will break the game logic.

    Instead of "Trigger once" use some condition like "is pinned" or "turret enabled". Instead of "Wait" use the Timer behavior to destroy guns.

    I've almost perfected the function. One problem I have now is that when I create the gun very quickly, the base gets destroyed quickly before unpinning the machine gun. This error happens when I create guns quickly in a shorter period; if I create them slowly, it works perfectly. Can you please help me fix this?

    Create:

    Destroy:

    Error Video: webmshare.com/play/bG6zm

  • Try these changes. Don't use "Trigger once"!

  • Try these changes. Don't use "Trigger once"!

    It works great!

    Thank you very much

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