Magic Leap Raycasting - Direction

Hi! I’m working with Magic Leap, and I’m trying to set an object direction using another direction between 2 raycasted points. I’ve been using this script but it doesn’t get the right direction actually. Thanks in advance.

if (_controller.IsBumperDown == true && lastPressed == 1 && secondsCount >= 2)
                    Debug.Log("Segundo Presionado");
                    secondpoint = result.point;
                    var angle = (secondpoint - firstpoint).normalized.y;                                      
                    Debug.Log("Angulo rotación:" + angle);
                    var rotation = Quaternion.Euler(0, angle, 0);                    
                    objToPlace.transform.localRotation = rotation;

Use the quaternion LookRotation method. As it looks like you wish to just rotate on the y-axis, set the y value to the same or zero on both vectors before creating the rotation.

var p1 = firstPoint;
var p2 = result.point;

p1.y = 0;
p2.y = 0;

var targetRot = Quaternion.LookRotation(p2 - p1);

objToPlace.transform.rotation = targetRot;

Thanks a lot man. Didn’t try it that way. It works fine now.