I have 2 objects. It will be in various direction and distance.
How can i instantiate objects between them with a specific distance.
I have 2 objects. It will be in various direction and distance.
How can i instantiate objects between them with a specific distance.
My suggestion would be to calculate the vector between the two objects, like this
Store the magnitude of that vector
Then, normalise the vector;
Iterate through the line, instanciating the object you want to create a specific distances
What that will do is set the initial point to be object1's position. It will then move a set distance along the vector between object 1 and object 2, check it's within the two objects, and if it is, instanciate the object, storing it in a list of gameobjects.
That hopefully should do it. I don't have Unity (or any IDE) in front of me to check the syntax.
Vector3.Lerp will determine the Vector3 location between 2 Vector3s at a specified percentage. 0.5 = 50%.