Quantcast
Channel: Questions in topic: "gun"
Viewing all articles
Browse latest Browse all 592

Why isn't my RPC shooting code working?

$
0
0
using UnityEngine; using System.Collections; public class ShootingScripts : MonoBehaviour { public Rigidbody bullet; void Start () { if (!networkView.isMine){ enabled = false; } } void Update() { if(Input.GetButtonDown("Fire1")){ networkView.RPC ("SpawnProjectile", RPCMode.All, transform.position, transform.rotation, 0); } } [RPC] void SpawnProjectile(Vector3 position, Quaternion rotation) { Rigidbody clone; clone = Instantiate(bullet, position, rotation) as Rigidbody; clone.AddForce(transform.right * 900); } } Does anyone have any idea why my bullets aren't firing when I press the fire key? I have the script attached to an empty game object which is attached to the barrel of the gun. I'm not getting any error messages, it's just not shooting.

Viewing all articles
Browse latest Browse all 592

Trending Articles