I’m working on an XR (MagicLeap) app and looking for a way to move my whole product assembly. The product is made up of 2/3 different meshes/BPs. I’m using a Raycast for the movement, which is activated using the trigger button on the motion controller, but currently the user can grab any component and move it independently. I would love some way to restrict the user so that only one mesh/BP is “grabbable”, or that when they select one object it automatically attaches the rest of them, so that everything always stays together. I hope that makes sense! It would also be really handy if I could use a slightly different input for this action (for example holding the trigger for 2 seconds to activate raycast) since the trigger is already being used to click widget inputs in the level, and I don’t want the product constantly being picked up and moved around by mistake. I would appreciate any help coming up with a solution to this, as I’ve been racking my brains for a long time, and I’m no expert when it comes to scripting! Thanks.
Gently bumping this, if anyone has any idea on how to assist?
I would love some way to restrict the
user so that only one mesh/BP is
Give the actor / component a tag and check if the tag is present before setting them as Target Actor. Move it only if it’s valid.
Use object types; so rather than sweeping with the trace against everything in the scene, you check only for objects of specific types.
or that when they select one object it
automatically attaches the rest of
them, so that everything always stays
I wouldn’t bother with attaching / detaching - this will probably complicate things. Depending on how things are attached together atm (actors / components / child actor components), you could try the Get Attach Parent Actor node in order to find the parent everything is attached to.
Get the hit actor and feed it to the node, if you get a nullptr, you’ve got the root - this is the actor you want to move; if not, walk up the chain and check again. This should work well even if you attach / detach stuff during run-time.
It would also be really handy if I
could use a slightly different input
for this action (for example holding
the trigger for 2 seconds to activate
The player controller can Get Input Key Time Down; check if the return value is greater than the time required and start tracing only if the threshold has been crossed.
Thank you @everynone - I used the LineTraceForObjects and it worked great. Setting custom object channels is really handy, I was not aware of that feature.
I struggled with the Get Input Key Time Down. I already have the controller triggers assigned in the camera (in attached imaged). How would I get the input key time down in this setup?
I used the LineTraceForObjects and it
It’s a very powerful system.
Get Input Key Time Down something like this should work ok:
You can do it in any blueprint as it queries the player controller for input.
Another approach would be to use a timer:
Atm it’s just a single ray after 2s but it could open a Gated Tick instead providing a continues trace is needed once the 2s have gone past:
Or even like this for simplicity’s sake:
It’s a design choice at this point depending on how you envisioned the desired functionality. It’s probably a good idea to choose one method and stick with, makes debugging a bit easier further on. If you’re going to use it often, it might be worth it wrapping it in a function.
Perfect, thank you!