- Home /
Question by
mblogest · Jul 25, 2018 at 07:18 AM ·
cameranetworkinglookatbillboard
problem with camera and look at in unity network
hi i want to create online game,i use
void CmdSpawnMyUnit()
{
// We are guaranteed to be on the server right now.
GameObject go = Instantiate(PlayerUnitPrefab);
go.transform.position = this.transform.position;
//go.GetComponent<NetworkIdentity>().AssignClientAuthority( connectionToClient );
// Now that the object exists on the server, propagate it to all
// the clients (and also wire up the NetworkIdentity)
NetworkServer.SpawnWithClientAuthority(go, connectionToClient);
}
for create a game object with local player authority ,and this game object have a health bar and this health bar look at camera,but my look at code and logic it work in offline mode but when use it in unity network health bar crazy and look like freezed camera. this is code of heath bar:
public class bilboard : MonoBehaviour {
public Camera cam;
public Canvas myhealthbar;
void Start () {
cam = Camera.main;
}
void Update () {
myhealthbar.transform.LookAt (transform.position + cam.transform.rotation * Vector3.back, cam.transform.rotation * Vector3.down);
}
}
i use main camera in scene,and healthbar crazy in host and client
Comment
Your answer
Follow this Question
Related Questions
Why does LookAt look away? 2 Answers
Mobile device as second screen 2 Answers
Player rotates with camera(face same direction as the camera) 1 Answer
Adding Multiplayer functionality 0 Answers
Lookat on local axis 2 Answers