In my current VR project, I have an en bloc clip to be inserted into an M1 rifle. I’ve created a point inside the rifle to attach the clip to once it’s overlapped, and have a clip that’s invisible on the gun model itself (since the clip to load it with is a separate blueprint). The clip becomes visible sitting on top of the raised follower inside the magazine. It looks like this in the blueprint:
I want to be able to then push down the clip into the magazine fully. However, once the clip is attached to the controller object, I don’t want it to be able to move up or move down past the bottom of the gun. I’ve already used the physics constraints to make it only movable on the Z axis, but is there a way to make it only movable within a certain range of the Z axis? Will the axis physics constraint work the way I believe it to?
Your first sentence seems a bit unnecessarily rude; I haven’t used this engine for all that long, and of course it stands to reason that I’m familiar with comparing two numerical values, but polling or checking synchronously for an object’s position seems to clash with the event-driven paradigm of the blueprints (which is reflected in the link you provided). You have an update scaler and update scaler stop event, but from where are these called? It seems in my case they would be called every frame/delta time as long as the grip button is held, but from where is this accessed?
Generally, when grabbing a component in Unreal Engine, attaching a component/actor to another is what’s used, which overrules any manual change in location one could achieve, so simply limiting to a nebulous “hand Z” wouldn’t work. I’ve tried some vector math to obtain the z-component of the vector generated by finding the angle between the up vector and the vector of the origin to the motion controller. However, despite my math being correct, it would come down to rotating a vector by the world rotation of the gun object so the vector angle could be found, and this makes it so the entire rotation is taken into account instead of just the angle desired (meaning, when you rotate the gun forward and back, the clip moves up and down, which is not desired). I’ve also tried attaching the clip to a spline to move it, but the method I’ve found to do this requires the spline and follower object to be separate entities in the world, not two components of a single BP. It seems this is a rather complex problem; otherwise, there would be more resources and examples for it instead of most people just relegating the task to external plugins.