Search Unity

Shooting a gun over UNET, am I understanding this correctly?

Discussion in 'UNet' started by Jordii, Oct 25, 2015.

  1. Jordii

    Jordii

    Joined:
    Sep 14, 2010
    Posts:
    135
    Hey guys,

    Currently I'm playing aroung with UNET for a bit, and I was wondering whether I am getting this correct. I wanted to have a player shoot a gun he's carrying, which's direction is separate from the player's looking direction. So as a player, I'm sending a signal on when I start/stop shooting, and another one with my aim direction. Sending my aim direction (Vector2) upon each change with my mouse seems the way to go.

    However, seeing there is no way a server can check whether this is the direction the player intended to shoot, I don't feel it's necessary for the client to send the start/stop gun signals through the server, but would rather send them to all, like in the legacy Unity networking. The server of course will do the hit detection, and whether he has enough ammo, but I'd like to cut out the server, just so things are a bit faster.

    Now I've delved a bit into messages, but from what I've seen, also messages are being sent to the server from the clients, and only the server can send to all.

    Are the things I described above correct or are there other, better ways?
    And, depending on whether it's a smart idea, would I be able to send a message from a client, to other clients?