Rotate towards Vector3

I have searched through numerous threads about this and still can’t grasp how this is supposed to work:

I have 2 Vector3 points (spawnPosA and spawnPosB), and from them I get elementObjectLocation using Lerp which works correctly (basically the middle point). On that point I instantiate my prefab which is basically a cylinder. I want the top of my cylinder to face point spawnPosB (or spawnPosA, the result should be the same). I have attempted to use “Quaternion.FromToRotation”, “Quaternion.LookRotation” and can’t figure out how it works. I have also tried to manually calculate angles and use eulerAngles but that turns out to be even more of a trouble.
My code, without any rotation attempts:
public void SpawnPipe(Vector3 spawnPosA, Vector3 spawnPosB)

  • {*
  •  int i = SpawnPoint ();*
    

_ elementObjectLocation = Vector3.Lerp (spawnPosA, spawnPosB, 0.5f);_

elementObject = Instantiate (Resources.Load (“ModelPrefabs/Pipe1”), elementObjectLocation , Quaternion.identity)as GameObject;

* //Insert rotation code here*

_ elementObject .transform.localScale = new Vector3(1,Vector3.Distance (spawnPosA, spawnPosB),1); //this one is to stretch the object, does not affect the result
* }
Here is a picture I drew if I did not explain that pretty well:
![alt text][1]
[1]: http://i59.tinypic.com/2cyjs6t.jpg*_

For a cylinder you want this for rotation:

 transform.rotation = Quaternion.FromToRotation(Vector3.up, spawnPosB - spawnPosA);

This will point the top side of the cylinder at spawnPosB. Reverse the order of subtraction to reverse the direction.

Note that a cylinder is 2 units high, so your scaling should be:

 elementObject *.transform.localScale = new Vector3(1, Vector3.Distance (spawnPosA, spawnPosB) / 2.0f, 1);* 

See this answer:
Rotating an object between 2 points - Unity Answers