I am trying to make a simple weapons cycle for a simple fps I was making for fun. I decided for weapon cycle to try to instantiate the prefab and parent it to where it belongs (Not sure if this is best way to do a weapons cycle if not let me know). However I can’t seem to instantiate it correctly. I am also stuck on how I would parent it. Thanks in advance.
using UnityEngine;
using System.Collections;
public class WeaponSwitch : MonoBehaviour {
public GameObject Magnum;
public GameObject Player;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown("1"))
{
GameObject obj;
obj = (GameObject)Instantiate(Magnum, Player.transform.position, Player.transform.rotation);
}
}
}