No announcement yet.

Array not indexing items

  • Filter
  • Time
  • Show
Clear All
new posts

    also, no matter what I try, it spawns more actors than I tell it to. Very frustrating


      Click image for larger version

Name:	4.png
Views:	1
Size:	249.4 KB
ID:	1131000
      It just always spawns more actors than I want.
      Click image for larger version

Name:	4.5.png
Views:	1
Size:	780.7 KB
ID:	1131001
      Click image for larger version

Name:	5.png
Views:	1
Size:	696.2 KB
ID:	1131002

      I put a print string at the end. so I see it's spawning a few entries of the index multiple times. Does anyone have any idea why this is?

      I thought it would only execute the spawn actor once for every entry of the array
      Click image for larger version

Name:	6.png
Views:	1
Size:	638.6 KB
ID:	1131003

      ALSO I changed the Collision Handling Override.. and it seemed to spawn the correct amount of actors now.. but the print string was still telling me that extra players were spawned..
      Last edited by mabdog; 07-12-2017, 11:33 AM.


        If you changed the collision so that the actor does not block itself practically, then they may be spawning inside each other. To see actors in the world, you can look at the world outliner (top right by default).

        The issue is probably one of two: either the wrong number of elements is in the players array (some duplicates) or that function has some logic issue. In order to determine what may be wrong you need to post the whole function.

        To debug, print the length of the players array before the loop, and inside the loop print each element.


          so are you saying I will be able to see the actors that spawn during runtime in the world outliner while it's simulating?

          I will try your method of debugging.. but here are the images of pretty much all my BPs. If there's anything I left out let me know:
          1. Create Player Input Fields (GameStartFixed)
          Click image for larger version

Name:	1. Create Player Input Fields (GameStartFixed).png
Views:	1
Size:	295.6 KB
ID:	1131026
          2. Add to "Players" Array (GameStartFixed)
          Click image for larger version

Name:	2. Add to 'Players' Array (GameStartFixed).png
Views:	1
Size:	265.2 KB
ID:	1131028
          3. Set Player Names And Spawn Player AIs, Then Update Player Names and Set Player Pawns in GameInstance
          Click image for larger version

Name:	3. Set Player Names and Spawn Player AIs. Then Update Display Names and Set Player Pawns in Game.png
Views:	1
Size:	493.5 KB
ID:	1131029
          4. Print Player Names To Screen (ATFYCRGameInstance)
          Click image for larger version

Name:	4. Print Player Names to Screen (ATFYCRGameInstance).png
Views:	1
Size:	216.0 KB
ID:	1131030
          5. Attempt
          Click image for larger version

Name:	5. Attempt.png
Views:	1
Size:	712.5 KB
ID:	1131031
          6. Result
          Click image for larger version

Name:	6. result.png
Views:	1
Size:	622.5 KB
ID:	1131032


            Yes, the world outliner will display spawned actors during PIE (Play in editor).

            Click image for larger version

Name:	Suspect.png
Views:	1
Size:	153.6 KB
ID:	1131049

            What happens after that screenshot ends? Is that where the "atfcyr" widget is created? If so, you're creating a new widget on every loop, each time incrementing the players to the new instance.
            So in the example of 3 players showing 6 actors, you can see that when the first widget is created, It only has one player name, outputting name 0 to the screen. The next has 2 players, outputting 0 then 1 to the screen. And so on.

            Though this could have happened inside any class, I would avoid putting game logic inside widgets.


              oh ****.. that needs to be on "completed", not loop body
              ooh this might be the root of the problem. I'll try to fix this later
              and I'll see about doing my spawning in a different BP (not a widget)


                so I got this system working, and the turn rotation. But I forgot to compile before simulating and it somehow permanently crashed my project (won't open anymore:
                fortunately most of my BPs are right here for me to reference lol


                  Ok, I've rebuilt this project and I'm at another roadblock.
                  And I can't seem to find an answer anywhere..

                  I want to have the camera follow the player as he moves to his next destination.
                  My first attempt I used a move to location node on the player controller. He moved to the correct location and the camera followed him correctly. The only issue with this was I didn't have a way of determining when the character finished moving to the destination. So I considered using an AI controller so I could use the built in ai components to determine when he completes his move.
                  I unpossesses the player controller
                  And possessed with the ai controller
                  Now the character moves, but the third person camera does not follow the character anymore.
                  So I'm just looking for a solution.
                  I need either a way to continue using the camera in the third person BP while the ai controller is controlling the character
                  Or a way to create a seperate camera in the level to switch to that will follow the active player along his path.
                  I can't figure out how to do either of these things.

                  Here is my trail of destruction:
                  Forum Post
                  Answerhub Post 1
                  Answerhub Post 2

                  I even have the turn rotation ready. but I need to sort this out first.