Here is my setup: I have a basic Character blueprint for a player that I’ve set up some basic controls for moving. I have some cubes in my level that I want to be able to go up to, press and hold a button to pick the item up and move it with the player, then drop it when I release the button. I’ve messed around with this a lot, but have gotten no where. I don’t have a blueprint to show, but I do have some screens of the situation, and you can see the sphere trigger I want to use to detect overlap, but I can’t seem to get any overlap event from it, and yeah, I’m new to this, so try to be specific. Any suggestions are appreciated.
both, cube and ball, need to have the collision type of the other on overlap.
- drag from “on event start overlap” the actor and cast whether its your needed object. if yes store it as a reference in a variable
- “on event end overlap” you clear the variable
- if you press the button, grab the reference variable from step 1. and attach it to your player. (you can also make an “is valid” check, so he doesn’t execute the code when the reference variable is empty )
- on button release you “detach from parent” the reference variable.
As an alternative to attaching it to your player, you could go down the route of using a ‘Physics Handle Component’ which will emulate a sort of dragging of the object through the air so that the picked up object does not look for rigid.
Here is a really good tutorial from the Wiki which should be relatively easy to adapt for your requirements.
Hope it helps,
I’ve followed the tutorial in the link, and it is doing some of what I want. I would like for the object I pickup to maintain it’s rotation relative to the player and not the world when I move around, but not snap to the rotation of the physics handle when I pick it up. I also want to be able to rotate the object with keys, on an axis relative to the player, so if I pickup a box from whatever side, and press e, I want it to rotate clockwise, but I can’t seem to get that to work, it always rotates the box based on the boxes own axis. Some things i’ve tried, is setting up a scene component, using the scene set the physics handle rotation, and rotating ‘add to rotation’ of the scene component, and setting the rotation of the scene component to the box on trace hit, so when it picks it up, it doesn’t snap to the rotation of the physics handle. Anyway, I know this is sounding all too confusing, so let me clarify what I want the end result to be.
I want to pickup the object, keeping the objects own rotation on pickup, but when the player moves around with it in the world, I want the object to rotate with the player. I want the player to be able to rotate the object clockwise and counterclockwise based on which face of the box the player is looking at, and not based on the boxes own axis.
Maybe i’m asking a lot, will keep experimenting. Thanks for the help so far, has gotten me a lot further than I would have on my own, and learning a lot.