Search Unity

How do i spawn object on player join?

Discussion in 'Multiplayer' started by jomsa, Oct 23, 2016.

  1. jomsa

    jomsa

    Joined:
    Nov 10, 2013
    Posts:
    23
    Ok, so this is the case:

    I want to spawn an rigidbody object for player when he joins the multiplayer game. Player should be able to issue commands for this rigidbody (owned by server) to make it move. (goal is to have server deal all physics simulation and just sync position and rotation to the client).

    I think i have sort of got that part to work Ok. The problem is.. for some reason when client joins he spawns multiple obects and the control goes haywire. (hard to explain what is happening).

    I am doing the spawning on Player object, script on Start(); ( i assumed it to be run everytime new player appears).. . and i network.instansiate the rigidbody object there... Also the client objects dont appear on host's screen.

    How should i spawn rigidbody object, that the server controls when player enters?
     
  2. jomsa

    jomsa

    Joined:
    Nov 10, 2013
    Posts:
    23
    Additional information:

    The root of the problem was, that i managed to spawn player objects as rigidbodies and all their controls and spawning worked right, but the rigidbody collisions were strange. As if the two objects on collision just sucked up their momentum energy. So i thought the server needs do do all the simulation thus we arrive to the current problem.