Pick not working inside for loop?

0 favourites
  • 14 posts
From the Asset Store
For Adventure, Action, Heroes, Sci-fi and Action-RPG games.
  • Hi. I did everything that came to my mind, but I can't make the Pick inside the for loop to work. Any ideas why?

    Tagged:

  • since we can't see much of your code, it is hard to say...

    does the textDebugging list all the enemy IDs? If the enemies were just created, they will not be pickable until the next top level event.

    or if this is a subevent that has filtered the enemies, they may not all be selected (then you would have to use a Pick All before your loop.

  • textDebugging is just a text that I'm using to see the outputs of whatever I'm trying to do.

    Also, I already created the enemy sprite before executing that "code" in the picture. I only want to update the instance variables of the enemy sprites.

  • I tried what you've said about using Pick All before the loop, it's still not working. :(

  • Please send help :(

  • Run the game in Debug Mode, check enemy instances and their IDs. Check the contents of the array. Maybe you will be able to see what's wrong.

    By the way, your loop should be from 0 to (Enemy.count-1)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I already did that and they both contain the same values.

  • How do you know that picking doesn't work? Have you tried moving that textDebugging action into the sub-event?

    Like Allan said, it's difficult to understand what you are trying to do from that screenshot. You need to explain what all these IDs and arrays are for, or post your project file.

  • Sorry about that. Here is what I'm trying to do:

    The active_enemy_array contains the values for the instance variables of each enemy sprites.

    The textDebugging is just a simple text which I use to see if the values I'm getting are correct.

    And yes, I tried moving the textDebugging to the sub-event and it still doesn't work.

    I already have the existing enemy sprites with their corresponding instance variables. Then what I wanted to do was to update each enemy sprite after they were hit with a bullet. I wanted to change the other instance variables' value based on the enemy sprite's ID.

  • Anyone? :(

  • If you are saying that ID instance variables match IDs in the array, then your loop should work. If you can't fix it, you'll need to post your project file.

    Why are you duplicating all variables in the array? If you are not saving the array in local storage or uploading it somewhere, then I don't see why you might need it.

  • Can I just email it to you again? :)

  • Yeah, ok

  • Thank you very much :)

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