Question by
Sebeus · May 18, 2016 at 04:35 PM ·
networkingmultiplayerdestroy object
Networking, destroying an object only on one of the clients
(I am new to networking so this might be a stupid question.)
I was having trouble instantly spawning objects on the client, so i did this:
void Update() {
if (isLocalPlayer) {
if (Input.GetKeyDown (KeyCode.E)) {
GameObject tempProjectile = Instantiate(bulletPrefab, bulletStartObject.transform.position, Quaternion.identity) as GameObject;
CmdShoot (bulletStartObject.transform.position);
}
}
}
[Command]
void CmdShoot(Vector3 pos){
GameObject g = Instantiate(bulletPrefab, pos, Quaternion.identity) as GameObject;
NetworkServer.Spawn(g);
}
The only issue is that this will spawn a second projectile on the initial client. I can't figure out how to destroy the second projectile on the initial client. I tried a few things, but none of them worked. So is there a way to destroy a spawned object on only one client?
Thanks for the help.
Comment
Your answer
Follow this Question
Related Questions
Increasing CCU's on UNet?? 0 Answers
Multiplayer Camera Rotation On Client 0 Answers
UNET match making without the relay server 3 Answers
Android multiplayer using WiFi 5 Answers
[uNET] Instantiated gameobjects not syncing for new clients 1 Answer