dictionary key value to spawn player

0 favourites
  • 9 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • hey all, please help I'm stuck,

    how to spawn each player from key dictionary?

    For example, look at the pic, how do you spawn a sprite/player every time the key dictionary is filled?

    Tagged:

  • You are using a wrong loop. Instead of "System -> For each dictionary" you need "Dictionary -> For each key"

    Inside the loop you can use Dictionary.CurrentKey and Dictionary.CurrentValue

    .

    Another option is to use "System Repeat Dictionary.keyCount" loop.

  • thank you for responding,

    I've changed my code like this, and loop for each key, but what happens after the key dictinary is filled with one key, but it spawns a sprite/player infinitely?

  • the problem is in the loop, sorry I explained simply and straight to the point I don't really know the whole thing because some of it was helped by chatgpt

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The second event on your screenshot runs on every tick (60 times per second or more). That's why the objects continue spawning.

    Any events which are not triggers or functions run on every tick.

    You need to put the loop inside some triggered event, for example "On start of layout"

  • I just want to spawn sprites from the key dictionary, for example the key dictionary is filled with keys "test1" then I want to spawn a sprite with the name "test1" which means spawning a sprite taking properties from the key dictionary,

    The sprite I mean is a player object that has information, such as a name or method

  • If you want to spawn those object when the layout starts, move the loop into "On start of layout" event.

    On Start of layout
    ... Dictionary for each key : Create object by name Dictionary.CurrentKey
    
  • no...I want to spawn sprites when the dictianory is filled with keys, let's assume this is a websocket multiplayer game that is set up using inputform,

    how many players?: not defined, depends on how many people are playing,

    The input form has been provided to manage the game in the form of filling in the username and value, "username" which will be entered into the key dictionary and "value" will be used for the "username" method.

  • .I want to spawn sprites when the dictianory is filled with keys, let's assume this is a websocket multiplayer game that is set up using inputform,

    In this case spawn the sprites in the same event where the keys are added to the dictionary. Or in some other event which is executed once.

    Just don't place the loop as a top-level event, because then it will run on every tick and spawn the sprites infinitely.

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