Download

Help to figure out how to rotate a static mesh in game

Hey everyone!
Im using the first person template and what I would like to do is allow the player to look at an object click and hold the mouse button and then attach the object to the player while maintaining its distance/translation/rotation from the player but following the camera movement (think looking at an object and moving it with your mind, head movement would translate the object) until releasing the button and then detach the object ( currently I do a trace from the camera component to locate and then attach targeted object although rotation snaps to I think the players current rotation). I think I have that part figured out minus the unwanted snapping, but the next part is to then click the mouse button and hold again on the object and rotate it in at least 2 axis with the mouse. The problem is, I need to stop the player from rotating while in this “object rotation” mode, and once the mouse button is released, regular player movement with no attached object (the default state) would begin again. I am unsure as to if this can all be handled on the character blueprint or if I need to make object blueprints similar to the mouse interaction content example. Any help would be greatly appreciated. This is targeted for an oculus/gearvr but I would assume the mechanics to get the functionality should be similar excluding the free look the HMD would provide.

No ideas huh?

Perfectly doable, and quite simple to stop player rotation while object is rotating. Just make a variable in your game mode blueprint like ‘CanRotate’, it should be a Boolean. Check the editable checkbox. Go into your characters rotation code, and set a branch for each rotation, and have it only execute if ‘CanRotate’ is true. Now make it so that when your object rotation begins, ‘CanRotate’ is set to false, and vice versa when the object rotation stops. You will need to cast to game mode every time you want to access ‘CanRotate’ here’s how to cast:718c7003c7bad79665d76fa3fb55afd23a3712c9.png

Thank you very much! I’ll give it a try when I get home today.