My take on grabbing the chair

Hey guys!

So here’s how I’d do it…

If we’re using a “beam” to find things, it needs to have a starting point and an end point. I’d create a component and use it’s location as the start of my beam, get my component’s forward vector (it needs to be positioned withing my pawn so that it actually points forward =P ) and multiply it by an arbitrary distance for the end of the beam to be at.

I’d then (I only know this because of blueprints, so it might not work quite like this in C++) create a line trace using my start and end points inside my pawn’s tick component so that it gets fired constantly.

To pick the item up i’d use an attach to component function and maybe use a certain key to detach the item and drop it back to the world.

To decide which items should be picked up and which ones shouldn’t, I’d check if the actor getting hit by my beam is of a certain type, making sure the grabbing function only kicks in if the actor matches my criteria.

I think that’s it. =D

Privacy & Terms