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.
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.
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.
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.
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.
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:
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.
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.