It sounds like a really simple question, but it's a problem I'm having and I've been unable to find a response yet.
I'm currently doing a few tests to set up a tower defence game eventually - and I've put a test prefab called "Cube" in a folder called Enemies, in project view. I have tried using the following code:
object=Resources.Load("Cube"); transform.position.x=Random.Range(-4.5,4.5); obj=Instantiate(object,transform.position,transform.rotation);
It's attached to a spawner object which will move to a random x location and create the Cube prefab there. It's quite obvious that the Cube part is the problem - and that's definitely its name.
However, it's in a folder called Enemies, which I assume is the problem. At this point, it's not a specific problem that I have to have everything in folders - but sooner or later this organisation will be essential so I may as well nail it now.
Could anybody please help me with how to reference an object in a folder?
On a side note, how would I have it let me drag the prefab in via the inspector? This would probably be a much easier method.
Thanks very much, Callum.