PlayerStarts and Spawning
This is maybe kind of a silly question and I found some similar topics in the forum and also on Google but none of them answer my question. How does the spawn system work in UE4? And is there a way to override it?
I have a soccer field level with total 7 PlayerStarts (3 for each team and 1 for the ball). Before the game starts there is a "Wait for other players" widget and after that, the server spawns all players depending on which team they are (Kind of like in Rocket League) I have dummy pawns as default pawn class that should all spawn at the same location but they spawn randomly (depending where the camera in the editor was, when the level was saved I believe)
Now is there a way to define on which PlayerStart the pawns spawn or do I have to make other objects (like target points or so) for my 7 spawn points and just one PlayerStart object?
Edit: I use Blueprints.
I thought I might resolve this since I now know whats actually going on with the cameras.
There is an option in the Class Defaults of Player Controllers called "Auto Manage Active Camera Target"
The way the camera flow works is like this:
So I guess the best way is to set the view target on Begin Play inside the Player Controller and not using dummy pawns for, in this case the "Wait for player" widget view.
For the actualy character spawning, use one of the above answers.
answered Oct 14 '18 at 11:40 AM
The key is your GameMode. This is where the logic goes to handle player creation. If nothing is defined in the game mode, the game will simply select a random PlayerStart. If no PlayerStarts exist, the game will use 0, 0, 0.
If you click on your player start object you'll see 'Tags' under Actor. This can be used to give your player starts an ID of some sort that you can reference in your blueprint. For example, you can fetch all of your player starts, then loop through looking for the ID you care about (using a Actor Has Tag node).
In your case I'd tag your PlayerStarts like:
Beyond that it's a matter of tracking state to figure out where to spawn. When you're trying to manually find a start position, you need to see if it's available (another Actor could have taken it already). Actor is available? Possess it! Try exploring Find Player Start in your Game Mode returning a PlayerStart actor (I also believe Choose Player Start is an option to explore as well). Feel free to dig into the API docs to see what's available (look for Blueprint functions, denoted on the left).
Might also dig into this re: respawning -- https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/RespawnPlayer/Blueprints/
Hopefully this gets you going! Let me know if you have further questions & I'd be happy to continue thinking this through with you.
answered Jun 20 '16 at 04:16 PM
Hello. I hope that this answers your question. I have made a function in the gamemode script that can be called at any time, such as when the widget detects that all players connected. Here is a picture of the function. I have used the location of the player starts as the transform. (The variables are vectors that were set to that location.) Hopefully this helps.
answered Jun 20 '16 at 04:23 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here