Unable to place item in original location that was picked up

Hi All.
I have created a character BP to pickup an item and place it back in original location. I have the script working but a couple of things that I have an issue with that makes it unusable.

  1. I get the actor with a hit (off key press from FPV camera) which is very picky on where I need to hit the object in the scene to pick it up from its stand on a table. From this I get it’s relative startLocation into a variable to use when placing it back before it appears to be in characters hand. I then get it’s relative endLocation into a variable to also use when placing it back.
  2. When I press key again to put it back I need to hit the stand as it cannot be placed just anywhere in the world. I’ve play close attention during testing and it appears to go back to the hit location on the object on pickup and end location is where I hit the stand. It never returns to proper location in the stand. At times it is below or in the table even though I do the lerp and use end and A and start as B into new character location.
    Screenshot 2022-03-11 163227

What I would like to do is as long as I am close enough to the object for picking it up not have to specifically hit the object but I have found no other way to pickup an object.

Here is a screengrab from a video showing the horizontal line from a line trace but mine goes straight from camera to the object so it is very difficult to get a positive hit on the object.
Screenshot 2022-03-11 163732

Any thoughts on what I need to do to correct these issues?

TIA!

Cheers!
Rick…

“What I would like to do is as long as I am close enough to the object for picking it up not have to specifically hit the object but I have found no other way to pickup an object.”

You could add a cylinder surrounding your Pawn with its collision set to ignore all channels except a custom one, named Interaction (overlap). Then , whenever you press the interaction key you could check the cylinder for overlapping actors. If the pickable object responds to this channel, you should retrieve it in a list of pickable objects.

I get the actor with a hit (off key press from FPV camera) which is very picky on where I need to hit the object in the scene to pick it up from its stand on a table. From this I get it’s relative startLocation into a variable to use when placing it back before it appears to be in characters hand. I then get it’s relative endLocation into a variable to also use when placing it back.

Use absolute world coordinates so nothing can mess up. Worst case scenario your object snaps back to the correct position. BTW I never use those player nodes I see on the image, I have a feeling you might be able to get a higher level of control through the Sequencer, but that is something I am not yet familiar with. Following this.

The best way is to make the actor a BP. Then you can give it a collision volume that’s larger than the object. Line trace to that volume, if you’re having problems because the item is too small.

Don’t, whatever you do, use the thing that’s all over youtube, where you can interact with an object simply because you’re near it. This is because you will find you can also pick up the object with your butt! :slight_smile:

You code looks fine, don’t use the sequencer, it’s not a portable solution.

You can make a ‘pickup-able’ blueprint parent. Once you have it sorted, you can place it anywhere and do this with any kind of object. If you did it in the sequencer, you have to re-do EVERYTHING everytime you decide to move the object, or use a new object.

It take the ‘code looks fine’ comment back, you have start and end the wrong way around :slight_smile:

Also, make sure the start and end are both calculated before the timeline starts, and that they are world locations.

I’m assuming the curve in the timeline just goes from 0 - 1.

Of curiosity, what do you mean with:

don’t use the sequencer, it’s not a portable solution.

Isn’t sequencer what animators use for cutscenes? Or is this old / bad tech?

Thanks for the reply! I tried world coordinates but then the object flies off into never-neverland I switch to TPV camera and cannot locate the object anywhere. I hit the “base” with the key to put it back and nothing can be found. So when I get the hit on the object I want to pickup before “moving” it to the characters hand I get the startLocation via relative coordinates. I have an empty object at the hand location and retrieve that after the move to endLocation again via relative coordinates. The start and end switching from A to B didnt change anything and thee object goes back but again looks to be off the hit of pickup and the hit on the base stand rather than going to original location.

I’ll keep trying.
Here is what I followed for the code: Picking Up And Moving Objects | Inspect Item Part 1 - Unreal Engine 4 Tutorial - YouTube

Rick…

Thanks again. Yes the start and end are saved before timeline and yes 0-1. The code is working as I stated its just not going to the specific location and sometimes the object isnt in the hand but the wrist area and the object is slightly rotated about Y axis??? Whjat I did to get the correct location I want to see the object is in the character BP in the viewport I added in my object (child actor to the FPV camera) and aligned it just so. I then added another child actor (arrow) and copied and pasted location coordinates of the first child actor so the are in the exact same location and rotation. Picked up object never goes to the hand but the wrist area and putting it back never goes to where it was first picked up as I would expect.

Thanks again…I’ll keep trying different things here.

Rick…

The video is a bit much though , 25 minutes :smile: . “Flies off into neverland” can mean a lot here but actually flying would require a physics implementation wouldn’t it, so after inspecting bits of the video I see the person on the video respawns the inspectable object which can cause trouble on its own (like not spawning or spawning with a relative offset to avoid collision). This video helped me a while back:

Which goes through a different approach using a physics constraint on the original object (instead of respawning) and explains a few things about collision as well. Maybe this shows you something the other video does not.

*Edit just a note I get shivers looking at your tutorial because storing all variables directly on the class instead of locally in functions is absolutely evil :slight_smile: and so is using delay nodes. Can’t recommend 10/10

Like I say, you can use the sequencer to move objects, but it is by no means a re-usable solution.

If you have a character moving around picking and putting down objects, the movement has to done with blueprint, otherwise you have to make separate sequence for EACH object. Which I’m sure you can see, is nuts… :slight_smile:

1 Like

Thank you very much. I will look into this video. I know the video does mention using physics but implies that can cause issues of its own. As for storing variables on the class vs functions I’m not sure what this implies? As well using a delay node to allow other code to execute…isnt that the point of a delay? Anyway will look into the video you shared.

Yes I have all this in a BP.

Cheers!
Rick…

When you are writing a function and need to store data temporarily specifically for that function, the data should be stored in variables local to that function. This is a best practice for various reasons.

Delay node got some downsides, it can not be called from within functions and disturbs the order of code execution. They are to be avoided unless absolutely required (and I never did require them). I call them ‘evil’ for this reason as code with delays is usually more difficult to manage than without.
*Edit: I also never use the event graph in blueprints for anything, if I ever have to add an event node, that node willl simply directly call a function on my class (responding to an input event, widget animation event, anim notify etc.) because adding everything on the event graph would just make a big mess of everything. So that is an additional reason why there are no delay nodes anywhere in my code.