Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace PUNTutorial
- {
- public class PlayerShoot : Photon.PunBehaviour
- {
- [SerializeField] Missile missilePefab;
- float nextFireTime;
- float fireDelay = 0.25f;
- void Awake()
- {
- enabled = photonView.isMine;
- }
- void Update()
- {
- if (Time.time < nextFireTime) return;
- if (Input.GetAxis("Fire1") > 0)
- {
- nextFireTime = Time.time + fireDelay;
- photonView.RPC("RPC_FireMissile", PhotonTargets.All);
- }
- }
- [PunRPC]
- void RPC_FireMissile(PhotonMessageInfo info)
- {
- var missile = Instantiate(missilePefab, transform.position, transform.rotation);
- missile.SetOwner(info.photonView);
- missile.gameObject.SetActive(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement