Hey guys, I have a script to instantiate prefabs in front of the player on a button press, but I need to get this script to work in multiplayer (spawns in front of the local player, and all the other players can see the created object), any help would be appreciated. Here is my script:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SpawnPrefab : MonoBehaviour
{
public GameObject player;
public GameObject gameobj1;
void Start()
{
//player = GameObject.Find(“player”);
}
public void ButtonInteract()
{
{
Instantiate(gameobj1, player.transform.position + (player.transform.forward * 2), player.transform.rotation);
}
}
}