Player Spawning at different location //Strange collision behavior

1) While i found a few old topics i didn't find any easy to use code example.

I want to spawn two ore more players at different locations in my game. Never should two players spawn at the same location.

Can you give me an example for to get this done?

2) While my first ride with photon was a simple 2D game, right now i try a 3d Game and whenever two Players collide with each other the models seem to fly slowly into the air or fall through the ground when that happens. (which they appearently should not do)

My guess is that i have to create a special collision behavior when using photon to avoid this. is there something simple to let Players who collide bump a few steps back and staying in place (y should not change) ?

While that is not what i want to reach in the end it would be enough to work with right now.

And one last question: When do i need a transform view? As far as i understand it is needed whenever i have moving objects on screen ?





Best Answer

  • Tobias
    Tobias admin
    Answer ✓
    1) Have a look at OnJoinedInstantiate.cs. It has the option to define spawning points and the SpawnSequence.Connection will distribute player based on their ActorNumber.
    This has one issue: When someone leaves and another player joins, this new player will not use the spot that became free. In fact, the ActorNumber can become > MaxPlayers.
    This can be handled with the PlayerNumbering.cs.
    Both scripts are only explained in comments but quite simple.

    2) There is no built in solution for this. Yes, you'd need to somehow make both players react to this and move back. Each user should do that on their own (and then their position synchronization will tell everyone else to reflect this back pedaling with a slight delay).

    3) You can use a TransformView to sync the Transform of some networked object :)

Answers

  • i thought about this a little: maybe i could avoid that spawning problem by spawning the players offscreen and then setting a fixed position where there are moved to. But then i have to know which ID they've got.

    Is the ID always going from 1 upwards?
    or a random number?
  • Tobias
    Tobias admin
    Answer ✓
    1) Have a look at OnJoinedInstantiate.cs. It has the option to define spawning points and the SpawnSequence.Connection will distribute player based on their ActorNumber.
    This has one issue: When someone leaves and another player joins, this new player will not use the spot that became free. In fact, the ActorNumber can become > MaxPlayers.
    This can be handled with the PlayerNumbering.cs.
    Both scripts are only explained in comments but quite simple.

    2) There is no built in solution for this. Yes, you'd need to somehow make both players react to this and move back. Each user should do that on their own (and then their position synchronization will tell everyone else to reflect this back pedaling with a slight delay).

    3) You can use a TransformView to sync the Transform of some networked object :)
  • Thx Tobias,

    that really helped a lot. I am glad that the game i am currently working on has no player changing in a middle of a session. So when a player leaves the play can't be played any further.

    the scripts are explained very well :)
    (had to try a few times but that just adds to the learning experience)

  • Glad this helped! Thanks for making the effort to actually dive into this.