i want the item to be be spawned at the location of a empty game object i have the variables all ready made if u need the whole script comment and ill post it
function Update ()
{
if (drop)
{
Instantiate (clone);
Instantiate (clone1);
drop = false;
Destroy (pick);
}
}
it works but im wondering if there is a way to make it the player it spawns on? i tried it works true but the prefabs i have set wont accept the player i have in the game granted it does 100% work im just wondering if there is a way to make it so were ever my character is the cube spawn there? ps- if u dont know thats fine im just wondering if there is a way?
If I understand you correctly, you now want to spawn your object at the location of the player. It should work just fine, if you put your Player position as the second argument, e.g. Player.transform.position (assuming Player is a GameObject).
// Create an empty object in scene
// Attach this script to any object in scene
// See: emptyObject.transform.position, emptyObject.transform.rotation
// Location and rotation are params 2 & 3 of Instantiate()
var emptyObject : Transform; // Drag empty object here
var drop = false;
var clone : Transform; // Drag your clone obj here
function Start() {
drop = true;
}
function Update ()
{
if (drop)
{
Instantiate (clone, emptyObject.transform.position, emptyObject.transform.rotation);
drop = false;
}
}
it works but im wondering if there is a way to make it the player it spawns on? i tried it works true but the prefabs i have set wont accept the player i have in the game granted it does 100% work im just wondering if there is a way to make it so were ever my character is the cube spawn there? ps- if u dont know thats fine im just wondering if there is a way?
– darkalIf I understand you correctly, you now want to spawn your object at the location of the player. It should work just fine, if you put your Player position as the second argument, e.g.
– ArkaneXPlayer.transform.position(assuming Player is a GameObject).