Search Unity

Bullets stuck in mid-air

Discussion in 'Multiplayer' started by Dawnreaver, Feb 27, 2013.

  1. Dawnreaver

    Dawnreaver

    Joined:
    Oct 13, 2010
    Posts:
    131
    Hey Folks ^_^

    I have a bit of a peculiar problem. For some reason the fired bullets keep getting stuck in mid air for no apparent reason.
    The bullets are rigid bodies that are instantiated on the network and have velocity added afterwards.

    For some reason the bullets of the player in his own running application work normal but they don't behave properly for the other clients i.e. they keep getting stuck randomly in mid air.

    I checked for any geometry that would be hidden or blocking to bullets but there was nothing and it happens randomly. Sometimes the bullets still behave the right way.

    Any ideas?

    Cheers!

    Dawnreaver
     
  2. login4donald

    login4donald

    Joined:
    Jan 3, 2012
    Posts:
    462
    How are you instantiating them? Have you used Network.Instantiate?
    When you do things over a network using just instantiate will work on the client its called to the others won't. Also if you are, have you need a network view to it?
     
    Last edited: Feb 27, 2013
  3. Dawnreaver

    Dawnreaver

    Joined:
    Oct 13, 2010
    Posts:
    131
    Yes.

    Code (csharp):
    1.  
    2. var bullet = Network.Instantiate(mgProjectile,bulletSpawnPointMG.position,bulletSpawnPointMG.rotation,0);
    3. var targetDelta = (transform.position - target);
    4. var launchVelocity = targetDelta.normalized * projectileSpeed;
    5. bullet.velocity = -launchVelocity;
    6.  
     
  4. Dawnreaver

    Dawnreaver

    Joined:
    Oct 13, 2010
    Posts:
    131
    So I found the solution to the problem:

    I created to RPC calls, one to send to every client that he was hit and a second to destroy the bullet.