Hello fellow people of the Unity community…
I have set up a local multiplayer game. I have now started trying to make a shooting component.
So far I have the bullet to be able to spawn (on all the players screens). Now comes the problem, the bullets are shot forward on the player who shot its side but they don’t fly forward on the other players sides. It also only shows the bullets the host shoots?
Thanks in advance:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class earthshote : MonoBehaviour
{
public Rigidbody Earthshote;
private float fireStart = 0f;
private float fireCooldown = 0.1f;
public float speed = 30;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetButton("Earth1"))
{
if (Time.time > fireStart + fireCooldown)
{
fireStart = Time.time;
Rigidbody instantiatedProjectile = Network.Instantiate(Earthshote, transform.position, transform.rotation, 0) as Rigidbody;
Network.Instantiate(Earthshote, transform.position, transform.rotation, 0);
instantiatedProjectile.velocity = transform.TransformDirection (Vector3.forward * speed);
}
}
}
}