Monday 15 April 2013

unity3d - Instantiate gameobject between 2 objects in unity 3d -


I have 2 objects that will be in different directions and distance.

How can I instill things between them in a particular distance? Enter image details here

My suggestion would be to calculate the vector between two objects, such as it

  vector 3 objectline = (object 2. Transformation.Sogition - Object 1. Transformation .);   

Store the magnitude of that vector

  float distance = objectline.   

Then, make vector normal;

  objectLine = objectLine.normalized;   

To create a specific distance, through the instaciating line,

  vector 3 creationPoint = object1.transform.position; Float creation PivetDistance = (object1.transform.position - object1.transform.position); Whereas (creativity & lt; distance) {creationPoint + = objectLine * NEW_OBJECT_DISTANCE; CreationPointDistance = (object1.transform.position- object1.transform.position); If (creation point distance> lie distance) {objects.ed (game object institute) (new object, creation point, new vector 3 (0.0 f, 0.0f, 0.0f)); }}   

What will be the starting point for the status of the object 1. This will then move a fixed distance with the vector between object 1 and object 2, check it within two objects, and if it is, then instanciate the object, storing it in the list of gamebacks.

Hopefully it should I do not have unity (or any IDE) in front of me.

No comments:

Post a Comment