PDA

View Full Version : Spawning two local player at startup



philippe.dion
04-14-2011, 05:04 PM
Hello everyone,

I'm kinda new with UDK so I decided to auto-learn it and I gave myself a little gameplay objective.

I want to make a simple fighter game "a-la" Street Fighter : Two players are fighting each other on a local computer. Movement is made as a sidescroller and there is only One viewport.

Now, I know that there is a first player that is automatically spawned when a map starts (the Login function on GameInfo). On my map, I put two PlayerStart points, where I want my Fighters to spawn at. The problem is, I can't find a way to spawn them on those spawn point by script. How can I specify that ?

I know that we can browse PlayerStart points by the WorldInfo :


ForEach WorldInfo.AllNavigationPoints( class'PlayerStart', N )

But when the first "Login" event occurs, it said that AllNavigationPoints collection is not yet initialized.

How can I then specify a PlayerStart point ?

It seems the engine then find a default spawn point where it spawn the Player's pawn. When this happens, I get this error log message :


DevSpawn: SpawnActor destroyed [Fighter_1] after spawning because it was encroaching on another Actor

like there was two Pawn that are spawning at the same point (but only one LocalPlayer that is loggin in at that point).

Now then on my GameInfo initial state, I spawn a second LocalPlayer. Again, I still get the same error message two times :


DevSpawn: SpawnActor destroyed [Fighter_2] after spawning because it was encroaching on another Actor


DevSpawn: SpawnActor destroyed [Fighter_3] after spawning because it was encroaching on another Actor

So, my three questions are :

- How can we specify a spawn location by script when an initial player logs in ?
- How come it seems two Pawn are spawned when a Player logs in ?
- Is there another alternative to manage players spawning at the beginning of a map ?

Any other advices or suggestions are welcomed !

Thanks :)

Phil

slowJusko
04-14-2011, 07:44 PM
Encroaching = spawning inside something.

philippe.dion
04-15-2011, 08:02 AM
Yeah, and this is happening because two players spawn at the same spot. (and also because two pawns spawn when each player logs in, and I can't find why)

Is there a way, by script, to spawn a player at a specific spawn point ? (when AllNavigationPoints are not available)

rogacz
04-15-2011, 09:03 AM
Take a peek at spawn(Actor) function. It has like 4 or 5 additional optional parameters, and one of them is position.

MonsOlympus
04-15-2011, 09:19 AM
You can also use your own form of spawn point if youre not happy with PlayerStart :cool:

philippe.dion
04-15-2011, 09:26 AM
That could be a solution,

and let's say I want a game designer to manually place the players Spawn Points in a map (a PlayerStart or a custom Actor), then how would you access those points in UnrealScript once you want to spawn your players ? (considering AllNavigationPoints is not yet available)

rogacz
04-15-2011, 09:28 AM
I think you can browse the world info for all actors in a map. That way you could locate your two custom play starting points.

MonsOlympus
04-15-2011, 09:37 AM
Oh damn I read that wrong, one second! You access them using the same iterator you showed at the top of the original post, just make sure it extends navigation points. What do you mean all navigation points arnt available?

philippe.dion
04-15-2011, 09:41 AM
This is where it gets tricky.

When the first player logs in (which is automatically triggered by the engine at the start of the map), the WorldInfo has not yet fed the AllNavigationPoints list, so I can't use it.

Or maybe I'm missing something ?
It seems to me what I'm trying to do is basic but I can't find where I got it wrong on this Engine.

MonsOlympus
04-15-2011, 09:44 AM
Do you know when worldinfo does get those? Its very strange its not filled while the map is loaded. Just store your own reference array in gameinfo and search foreach all actors in postbegin to fill the array with your starts. (wow jargon, you get that?)

philippe.dion
04-15-2011, 11:08 AM
Right, tks Mons, your last post made me realize I was maybe spawning my players too early and that is exactly what I was doing. I was spawning them on the InitGame event.

Instead of doing this I let the engine automatically spawn my first player and then I created an auto state in my GameInfo where I spawn the second player.


I still can't find why it said my first Player Pawn is encroaching on another actor though, like it was spawning on my actual PlayerController Actor??

Any reason why it would do so ?

Thanks for the help !

philippe.dion
04-15-2011, 11:44 AM
NVM,

I figured out that I was spawning another Pawn as a test on my camera state, which was causing the Encroaching error.


Thanks guys !