Search Unity

Question Assign Targets NGO?

Discussion in 'Multiplayer' started by ParsyXD, Mar 26, 2024.

  1. ParsyXD

    ParsyXD

    Joined:
    May 12, 2020
    Posts:
    16
    so, my problem is that i have spaceships, which the player can give orders, like attack an enemy ship, or attack a part of an enemy ship. problem is, with ngo i can only assign a networkobject reference. so i have to assign a network object reference as a network variable on the ship, and inside the ship code i have to constantly check if it's changed and if, convert the new one to a transform with *send to server*.
    and i can't set ship parts as targets because they don't have a network object component as a child object. ofc i could create a list of all parts and convert the index to target, but

    is there a better way to do all that? it feels like a bad solution
     
    Last edited: Mar 26, 2024
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,012
    What do you mean by that? As you say it, the statement is not true.

    No. I think you may be misusing NetworkVariables here where you should rather send an RPC message.
    Also NetworkVariable has OnValueChanged callbacks so there is no need to constantly check its value for changes.

    They don't have to. You are commanding the ships primarily to attack another ship. The "what ship part to attack" (eg left wing) is just extra information on top (like you say: an index or enum) that you pass into the RPC and the server can look up the ship, ask for its "left wing" part and use that child transform.

    The less objects with Network(anything) the better.
     
    bugfinders likes this.
  3. ParsyXD

    ParsyXD

    Joined:
    May 12, 2020
    Posts:
    16
    1.
    oh yeah i will use on value changed

    2.
    ahh i didn't even think of giving that as extra info and the ship as a target in general. yeah alright ig i have to create a list for the parts

    thx