#Finding the owned player object.

1 messages · Page 1 of 1 (latest)

woven delta
#

As the title suggests i am trying to find and read the "health" component from only the player i control and own; then i want to display said data on my ui, managed by another script, not tied to the player prefab. how do i go about finding and referencing only the local player gameobject/networkobject? Im using fish-networking.

void basin
#

are you try to find the health component in owner side or any client side?

also FishNet community are very friendly, you could ask them too.

if im read it correctly seems like you want to find a health component in owner side (the one you control it)

void basin
#
var localPlayer = InstanceFinder.ClientManager.Connection.FirstObject;

// Get health component
var health = localPlayer.GetComponent<PlayerHealth>();```
blazing rapids
#

in player you can have a public static Player LocalPlayer

#

and then do something like cs public override void OnNetworkSpawn() { if (IsLocalPlayer) { Player.LocalPlayer = this; } }

#

@woven delta

#

oh i just noticed youre using fishnet

#

im not sure what the fishnet equivalent of isLocalPlayer is

#

but the same principle should apply

woven delta
#

Thank yall