Trying to make an object (currentItem) drop on the ground where the Player is. Given this error when trying
BCE0023: No appropriate version of ‘UnityEngine.Object.Instantiate’ for the argument list ‘(String, UnityEngine.Vector3, UnityEngine.Quaternion)’ was found.
Here’s the Code
//Script Written By InsanityStudios [Nightbird0]
//Converted and Edited By Lewis Comstive
//GUI Skin
var inventorySkin : GUISkin;
//Slots
var slot1 : String = "Empty 1";
var slot2 : String = "Empty 2";
var slot3 : String = "Empty 3";
var slot4 : String = "Empty 4";
var slot5 : String = "Empty 5";
var slot6 : String = "Empty 6";
var slot7 : String = "Empty 7";
var slot8 : String = "Empty 8";
var currentItem : String = "None";
//Other Variables
var isEnabled : boolean = false;
var timer : int = 500;
var messageInt : int = 0;
var messageText : String = "";
var Player : Transform;
var itemToDrop : Rigidbody;
var remove : boolean = false;
function Start() {
}
function Drop() {
character = gameObject.Find("Player").transform;
Instantiate(currentItem, character.position, Quaternion.identity);
messageText = "Dropped " + currentItem;
}
function Update()
{
if (Input.GetKeyDown(KeyCode.X)) {
Drop();
}
if(messageInt >= 0) messageInt--;
if(Input.GetKeyDown(KeyCode.Alpha1))
{
currentItem = slot1;
messageInt = 100;
messageText = slot1 + " Selected!";
ActivateItems(currentItem);
}
if(Input.GetKeyDown(KeyCode.Alpha2))
{
currentItem = slot2;
messageInt = 100;
messageText = slot2 + " Selected!";
ActivateItems(currentItem);
}
if(Input.GetKeyDown(KeyCode.Alpha3))
{
currentItem = slot3;
messageInt = 100;
messageText = slot3 + " Selected!";
ActivateItems(currentItem);
}
if(Input.GetKeyDown(KeyCode.Alpha4))
{
currentItem = slot4;
messageInt = 100;
messageText = slot4 + " Selected!";
ActivateItems(currentItem);
}
if(Input.GetKeyDown(KeyCode.Alpha5))
{
currentItem = slot5;
messageInt = 100;
messageText = slot5 + " Selected!";
ActivateItems(currentItem);
}
if(Input.GetKeyDown(KeyCode.Alpha6))
{
currentItem = slot6;
messageInt = 100;
messageText = slot6 + " Selected!";
ActivateItems(currentItem);
}
if(Input.GetKeyDown(KeyCode.Alpha7))
{
currentItem = slot7;
messageInt = 100;
messageText = slot7 + " Selected!";
ActivateItems(currentItem);
}
if(Input.GetKeyDown(KeyCode.Alpha8))
{
currentItem = slot8;
messageInt = 100;
messageText = slot8 + " Selected!";
ActivateItems(currentItem);
}
if(Time.timeScale != 0) timer--;
if(timer <= 0) isEnabled = false;
if(Input.GetKey(KeyCode.Tab) && isEnabled) isEnabled = false;
if(Input.GetKey(KeyCode.Tab) && !isEnabled) isEnabled = true;
}
function OnGUI()
{
GUI.skin = inventorySkin;
if (messageInt > 1)
{
GUI.Label(new Rect(40, 10, 500, 50), messageText);
}
if (isEnabled)
{
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 + 390, 100, 30), slot1))
{
if (!remove)
{
currentItem = slot1;
messageint = 100;
messagetext = slot1 + " Selected!";
ActivateItems(currentItem);
}
else
{
messageint = 100;
messagetext = "Slot Removed";
slot1 = "Empty 1";
remove = false;
}
}
if (GUI.Button(new Rect(Screen.width / 2 - 300, Screen.height / 2 + 390, 100, 30), slot2))
{
if (!remove)
{
currentItem = slot2;
messageint = 100;
messagetext = slot2 + " Selected!";
ActivateItems(currentItem);
}
else
{
messageint = 100;
messagetext = "Slot Removed";
slot2 = "Empty 2";
remove = false;
}
}
if (GUI.Button(new Rect(Screen.width / 2 - 200, Screen.height / 2 + 390, 100, 30), slot3))
{
if (!remove)
{
currentItem = slot3;
messageint = 100;
messagetext = slot3 + " Selected!";
ActivateItems(currentItem);
}
else
{
messageint = 100;
messagetext = "Slot Removed";
slot3 = "Empty 3";
remove = false;
}
}
if (GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2 + 390, 100, 30), slot4))
{
if (!remove)
{
currentItem = slot4;
messageint = 100;
messagetext = slot4 + " Selected!";
ActivateItems(currentItem);
}
else
{
messageint = 100;
messagetext = "Slot Removed";
slot4 = "Empty 4";
remove = false;
}
}
if (GUI.Button(new Rect(Screen.width / 2 - 0, Screen.height / 2 + 390, 100, 30), slot5))
{
if (!remove)
{
currentItem = slot5;
messageint = 100;
messagetext = slot5 + " Selected!";
ActivateItems(currentItem);
}
else
{
messageint = 100;
messagetext = "Slot Removed";
slot5 = "Empty 5";
remove = false;
}
}
if (GUI.Button(new Rect(Screen.width / 2 + 100, Screen.height / 2 + 390, 100, 30), slot6))
{
if (!remove)
{
currentItem = slot6;
messageint = 100;
messagetext = slot6 + " Selected!";
ActivateItems(currentItem);
}
else
{
messageint = 100;
messagetext = "Slot Removed";
slot6 = "Empty 6";
remove = false;
}
}
if (GUI.Button(new Rect(Screen.width / 2 + 200, Screen.height / 2 + 390, 100, 30), slot7))
{
if (!remove)
{
currentItem = slot7;
messageint = 100;
messagetext = slot7 + " Selected!";
ActivateItems(currentItem);
}
else
{
messageint = 100;
messagetext = "Slot Removed";
slot7 = "Empty 7";
remove = false;
}
}
if (GUI.Button(new Rect(Screen.width / 2 + 300, Screen.height / 2 + 390, 100, 30), slot8))
{
if (!remove)
{
currentItem = slot8;
messageint = 100;
messagetext = slot8 + " Selected!";
ActivateItems(currentItem);
}
else
{
messageint = 100;
messagetext = "Slot Removed";
slot8 = "Empty 8";
remove = false;
}
}
if (remove)
{
if (GUI.Button(new Rect(Screen.width / 2 + 400, Screen.height / 2 + 390, 50, 30), "Stop"))
{
remove = false;
}
}
else if (!remove)
{
if (GUI.Button(new Rect(Screen.width / 2 + 400, Screen.height / 2 + 390, 50, 30), "Remove"))
{
remove = true;
}
}
}
}
function ActivateItems(slot : String)
{
}