- Home /
How to instantiate prefabs between 2 objects like a path
Hi, i am trying to make a level generator using prefabs. I want to generate a path of prefabs between 2 objects. However! These instantiated prefabs have fixed sizes, and need to connect with each other. Eventually the purpose is that the prefabs will be instantiated in a grid-like manner. And each time the path would be different. A L shape towards the end position. Or just a "curvy" path towards the end position.
Attached an example:
I am not asking for an script, merely a push in the right direction. I honestly don't know where to start.
This is the beginning of the "test" script what i came up with.
var startNode : Transform;
var endNode : Transform;
var nodes : Transform;
var startPosition : Vector3;
var endPosition : Vector3;
private var distance : float;
private var center : Vector3;
function Start()
{
startPosition = Vector3(0, 0, 0);
endPosition = Vector3(startPosition.x + 5 * 5, 0,startPosition.z + 5 * 6);
Instantiate(startNode, startPosition, Quaternion.identity);
Instantiate(endNode, endPosition, Quaternion.identity);
GeneratePath();
}
function GeneratePath()
{
}
So the startNode and endNode will be instantiated(eventually at a random location). And between them the generated "path". Of course the code that i have posted isn't much. But like i said, i just don't know where to start.
I really hope someone can help me!
Thanks in advance and cheers, Darryl
Your answer
Follow this Question
Related Questions
How to randomly generate prefab? 2 Answers
Instantiate a random prefab at an objects location 3 Answers
Instantiating a random prefab from array. 1 Answer
Unity not Instantiating Prefabs Properly 0 Answers
Randomly pick then create prefab 2 Answers