Rotate a sphere based on a LineTrace

Hi everyone,

I want to have the following setup:
I want to rotate a sphere with the Oculus Controller by ‘pointing’ at the sphere and once I press the trigger the sphere rotates according the ‘hitpoint’ of my controller. So far I do a LineTraceForObject so I get the location of the hit result. However I cant figure out how to set the rotation of the sphere with the given hit results. Any help is appreciated.


1 Like

But what do you want to do? Rotate the hit zone toward the player, or away, or…

1 Like

Hello ClockworkOcean,

Let’s assume the sphere is a globe and I want to rotate it with my finger (in this case the beam of the controller) in a certain direction as long as the trigger is pressed. As soon as I release the trigger, the globe should stop.

1 Like

OK. Once you have a reference to the ball, you can just use AddLocalRotation, in the same direction you’re moving the finger.

1 Like

Unfortunately not, maybe my description was not clear:

I want to touch the sphere with the beam (red) at the green point and once I press the trigger I want to rotate (as an example) in the direction of the yellow arrow. Just using AddLocalRotation doesnt work.

1 Like

I’m assuming you click and hold while you move the controller?

Your movement, in this case, combines some Yaw and pitch, so it’s a local addition on two ( possibly 3 ) axis.

Am I missing the point? ( just re-reading that )

I was assuming you want to ‘grab and drag’, but this sounds more like the green dot should align with the front point.

1 Like

Yes, exactly. I click and move the sphere so it results in a Rotation of the sphere. I think I will need to calculate a vector from sphere-center to the hitpoint and transfer the rotation of this vector to the sphere, but my blueprint knowledge isn’t good enough.

If you put the sphere in a BP, you can always just find the difference between the touched point and the BP forward vector.

You have the vector you get from touching ( tracing to ) the sphere, which is the impact point minus the sphere center.

If the sphere is in a BP, the forward vector is known.

Then it’s just a case of translating one to the other.

I say ‘just’, because it’s probably pretty simple, but I don’t know off the top of my head how to do that right now. I can drop a bit of code in tomorrow.

1 Like

And then a quick google, gives me answering the question :slight_smile:

1 Like

Thanks, I’d appreciate. I already reached the point where I subtract the tracing point and the center position of the sphere. But I am struggling with the transfer of the rotation of the vector to the sphere.

1 Like

I’ll take a look today, I think there’s a simple method…


I’m doing a line trace to the sphere which is in a BP. The red dot in my trace.

When I click, I attach a green dot to the object. Then the BP rotates the sphere to bring the dot round to the front.

This is the calculation from the trace impact point

Then on tick:

sphere touch2


This is excellent, almost just what I need. Instead of clicking with the mouse I want to use the controller to drag the sphere around until I release. The problem I have now (and this relates to my lack of blueprint experience) is that when picking it always snaps to the same point:


This is the BP so far:

So I am almost there.


Out of sheer curiosity - what results are you expecting / desiring when the user drags too far to one side and the trace no longer hits the actor?

Hi Everynone,
right now if the trace is not hitting the sphere, the sphere itself just stop rotating. Ideally it could still rotate with a damping and then stop, which right now isn’t the case.

You can have another component be the one Looking at the HitLocation, and after the LookAt node executes have the sphete attach to that other component with the Rotation Rule set to Keep World. This way your other acotr snaps to look at the Hit but the sphere attaches to it right after. You can detach on release.

For example:

:point_up_2: Notice I’m telling the LookAt component to look at. This node runs before the Attach so the sphere misses that innitial snap.

You could achieve this enabling simulate physics on the sphere as the button is released:


You can then set a timer to disable it.


Hello pezzott,

I just looked at your deleted post, that looks very promising. Can you post the Blueprint since I am really a ‘blueprint dummy’

Idk if what I did is your best option.

Brought it back and will share bp later.

Thanks in advance

Ok… this is a bit messy, but hope commens help:

On the players side, there is a event dispatcher that is needed to bind the function here, this calls when LMB is released. Besides that he only checks if it has valid interface and calls it like it would any door or interactible.

Hope it helps.