// Update is called once per frame void Update() { if (PhotonNetwork.isMasterClient) { if (target == null) { PhotonNetwork.Destroy(this.gameObject); return; } this.transform.rotation = Quaternion.LookRotation(target.transform.position - this.transform.position); this.transform.position = Vector3.Lerp(origin, target.transform.position, ((Time.time - startTime) * speed) / distance); if (this.transform.position == target.transform.position) { ShipValues temp = target.GetComponent <ShipValues>(); if (temp != null) { temp.bulletHit(damage); } else { Debug.LogError("The target " + target.transform.name + " is not a ship (or hasn't values attached)."); } PhotonNetwork.Destroy(this.gameObject); } } }
public void changeShip(GameObject newShip) { if (ship != null) { placeholderShip = ship.transform; PhotonNetwork.Destroy(ship); } GameObject temp = PhotonNetwork.Instantiate(newShip.name, placeholderShip.position, placeholderShip.rotation, 0) as GameObject; ship = temp; ship.transform.parent = this.transform; shipValues = ship.GetComponent <ShipValues>(); }