I am getting no errors or anything yet when I start up the game and click the button to instantiate a prefab that I can move around it doesn’t work. The object doesn’t even show up. Why is this. I am creating this script that makes the movement and instantiation of the object avalaible and than I am calling it in another script for when I click a button. I am trying to get it so that the gameobject moves relative to your objects position and it should always be 15 units away from the camera until this certain point which I will add to the script later. Can someone tell me whyt his isn’t working. I have very basic knowledge on working with Vectorsa and such. Thank you for any help, here is the script:
using UnityEngine;
using System.Collections;
public class PlacingParts : MonoBehaviour
{
private Transform currentPart;
void Start ()
{
}
void Update ()
{
if (currentPart != null)
{
Vector3 m = Input.mousePosition;
currentPart.position = new Vector3(m.x,m.y,15);
}
}
public void PlaceItem(GameObject b)
{
currentPart = (((GameObject)Instantiate(b)).transform);
}
}
////////////////////////OTHER SCRIPT BELOW/////////////////////////////
//This is where I am calling the placingObjects script
//I stored the placingParts script in a variable and than //used it
GUI.BeginGroup (new Rect (0, 32, 565, 590), partSelectionBackground);
for (int i = 0; i< cockpit.Length; i++)
{
if(GUI.Button (new Rect((i % cols) * 91 + 10, ((int)i / cols) * 91 + 10, 81,81),cockpit*.name, partSlotButton))*
-
{*
_ placingparts.PlaceItem(cockpit*);_
_ }_
_ }_
_ GUI.EndGroup ();*_