This code completely works as it is, however I need the SpawnPos Vector3 to not be (0,0,0), I want it to be like
(assume “Player” is my character)
Vector3(2+“Player”,0+“Player”,1+“Player”)
So basically I want “Cube” to spawn relative to my gameobject “Player”
#pragma strict
var Inv : float;
var LargeInv : float;
static var WoodLog = 0;
static var CRWood : boolean;
var CANPlaceWoodLog : boolean;
var testCRWood : boolean;
/////WoodLogPlacement
var Cube : GameObject;
var SpawnPos;
function spawn_cube ()
{
SpawnPos = Vector3(0,0,0);
var tempspawncube = Instantiate(Cube, SpawnPos, Quaternion.identity);
}
/////EndWoodLogVars
function Start ()
{CANPlaceWoodLog = false; var Inv = 0; var LargeInv = 0; CRWood = true;
}
function Update () {
if(WoodLog > 0) { CANPlaceWoodLog = true;} if(WoodLog <= 0){CANPlaceWoodLog = false;}
if(WoodLog >= 2){CRWood = false;}
testCRWood = CRWood;
if(Input.GetKeyDown("1"))
{
if(CANPlaceWoodLog == true)
{
spawn_cube (); WoodLog = WoodLog -1;
}
}
}
Thank you for help!!