HELLO FELLOW UNITY LOVERS!
Okay my problem is:
I have made a script that when a player hits the input “Earth 2” it spawns a wall (Looks like a rock, made it in blender).
When the wall spawns it spawns in front of the player who used the input… but it also spawns the wall in front of the other players who didn’t use the input “Earth2” . How do I make it only spawn infront of the player who used it?
This is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class earthwall : MonoBehaviour
{
public GameObject Earthwall;
private float fireStart = 0f;
private float fireCooldown = 0.1f;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (!isLocalPlayer)
{
return;
}
if (Input.GetButton("Earth2"))
{
if (Time.time > fireStart + fireCooldown)
{
fireStart = Time.time;
GameObject InstantiatedProjectile = (GameObject)Network.Instantiate(Earthwall, transform.position, transform.rotation, 0);
}
}
}
}
ALSO:
isLocalPlayer is an error??
THANKS IN ADVANCE!!