Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Third Party Photon networking. how to instantiate a object precisely at the same time over the server? MOBA

Discussion in 'Multiplayer' started by vincekieft, Jan 2, 2015.

  1. vincekieft

    vincekieft

    Joined:
    May 18, 2013
    Posts:
    54
    hello everybody,

    I am making a MOBA GAME and i have some problems with my mage characters.
    when i fire with my mage character the animation starts and then the player shoots. but there is a small delay of a second or less but alot of times when the bullet hits the enemy on my screen the bullet misses the enemy on the enemys screen and then the enemy takes no demage?? in my moba you have to aim yourself like in SMITE.
    how does games like SMITE do that?

    plz help me

    greethings,

    Vince Kieft
     
  2. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    A good idea with PUN is to let the MasterClient handle hit checks, setting health and stuff like that. And then let the player handle visuals locally.

    The reason that they do not hit on each client is that no matter what you do then there will be a delay on other clients as a message is not instant (physically impossible). PUN got a timer that you can use. Send timer for when you shoot and when you receive it then check the time difference. Use this information to correct the visuals locally.

    In one of my PUN game i also check if i actually hit (raycast) locally and sends that as a parameter. If i hit on my computer i should hit on yours. But we will almost never be at the exact same position on our computers. So what i do is to actually change the direction of the shoot locally so that it looks like i am hitting with my bullet even though its not flying on the exact same path. We tested it and no one really notice, so it is visual deceiving but effective.
     
  3. vincekieft

    vincekieft

    Joined:
    May 18, 2013
    Posts:
    54
    can you explain a bit better in code maybe how to Sendthe timer and use that information to correct the delay?
     
  4. vincekieft

    vincekieft

    Joined:
    May 18, 2013
    Posts:
    54
    btw thanks alot for helping me :)
    how do you do this:

    "In one of my PUN game i also check if i actually hit (raycast) locally and sends that as a parameter. If i hit on my computer i should hit on yours. But we will almost never be at the exact same position on our computers. So what i do is to actually change the direction of the shoot locally so that it looks like i am hitting with my bullet even though its not flying on the exact same path. We tested it and no one really notice, so it is visual deceiving but effective."
    ?
     
  5. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Just use photon's networktime and send it as a parameter. How i correct stuff in my game won't help you in your game really. It depends on the scope and setup of the game.
     
  6. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    I use a raycast to see if i hit an enemy locally. If i do i send the ID of the enemy. Then locally i can correct the direction based on that player with the given ID's transform position.
     
  7. vincekieft

    vincekieft

    Joined:
    May 18, 2013
    Posts:
    54
    aah oke thanks men :) ill try