Create object on two different instances

0 favourites
  • 6 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hi there,

    I'm making a top-down game and I'd like to have a little smoke particle effect for when the player starts running.

    I can achieve that with these events:

    As seen on this gif:

    Now, the problem - in my game I have more than one player character. They're the same object and I've been using "pick" to pick the right instances.

    Using this same piece of code, if I have 2 players, if one player is already running the smoke will never appear on the player that has just started running:

    This seems really simple but I could not get it to work. I've tried having a boolean variable on the player character and setting it to "true" whenever he's running, and if it was true, it would create the smoke sprite once - but it didn't work.

    Anyone know how to deal with this?

    edit: I forgot to mention that I have also tried using a "For each":

    But then this happens when both players are walking:

  • Instead of using trigger once, cant you just add the smoke effect to the key press? Think that should solve it and you get rid of the checks every tick etc.

  • Instead of using trigger once, cant you just add the smoke effect to the key press? Think that should solve it and you get rid of the checks every tick etc.

    I thought of that but my entire key press events are after a loop... I have the same keypress events for all the players since they're the same object:

    So I would have to make more keypress events just for this, that would suck ):

  • Depends I would personally have made the key press on top level, just because they are "triggers" but that's just my way of doing it. But you can still do it if you add it to a function, then you can reuse your code if needed as well.

    Function Create_Smoke

    ---- Pick sprPlayer.UID = Function.Param(0)

    (Create smoke)

    You then just pass the sprPlayer.UID to it and if you find out you would like enemies or whatever to create smoke as well you can just extend the function

    Function Create_Smoke

    ---- Pick sprPlayer.UID = Function.Param(0)

    (Create smoke)

    ---- Pick sprEnemy.UID = Function.Param(0)

    (Create smoke)

    From you code that should work as far as I can see.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Or you can add additional keys to your code without having to change anything. Just add "On key press" separately of the ones you are already using as these will only trigger once automatically.

  • nimos100

    Thanks for the help!

    7Soul helped me out and did this:

    Now it works as intended. Spawning the object instead of creating it was the right way to go.

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