Simple 3D Question

I am having some issues, I need to have a 3D mesh added to the scene when I call function X. I’ve tried searching, but couldn’t find anything. I can add the object to the scene by just dragging it, but that won’t work since it needs to only appear in certain situations.

I also need to set the location of the object. I’m pretty sure I can set that with transform position, but right now the main issue is getting the object added to the scene via JavaScript.

Resources.Load("Weapons/Gun", GameObject);
transform.localPosition = Vector3(-0.2001977, -0.907091, 2.249809);

You need to instantiate the object from within your script.

Something like this?

function loadObject() {
Instantiate (gunMesh);
gunMesh.localPosition = Vector3(-0.2001977, -0.907091, 2.249809);
}

This didn’t work, not sure what I’m doing wrong :confused:

Got it working, thanks for the link. Making the transition from AS3 and kinda screwed it up the first time :slight_smile: