How would one create a gravity gun?

As the question suggests, I am looking for a way to create a functional gravity gun in UE4 which is able to pick up objects a certain distance away, and place them down again - and possibly fire them away. What would be an effective way of creating this functionality?

Thanks in advance,

Chronozoah

Something like this? GravityGun - YouTube

I like the ending ^^

Ok so I just edited MyCharacter BP from the First Person Shooter project that Epic made.
Here is an image of the component that I added. Just a Sphere component that I put a ways from the character and made sure hidden in game was ticked. This is just used for the location reference.

Next we have the graph and well, you asked for it :stuck_out_tongue: its hard to go over everything but basically the character sends a trace from himself to the Point of Contact, which serves as a weapon range of sorts also. Anyways, if it hits something, it will grab that object and turn its simulate physics off. As long as the fire input is not released, it will continually keep the object on top of the Point of Contact component. Once the fire input is released, the Simulate Physics is turned back on and the object is released and behaves based on its Physics properties.

It was a pretty vague request, but I hope that this could give you some insight. I had fun doing it anyways. And there is certainly room for improvement!

Fairly interesting. I am not looking to make one myself at the moment, but it could come in handy

I get the same issue you had - crashes the system. Are you able to provide any more details or alternatives? I’ll have to give it a look over again later.

Thanks again.

Hmm I had assumed that I was crashing because I had force deleted a bunch of epic’s content in that test project and figured it was causing issues. I’ll look into it.

Ok, I deleted all the brush geometry in the level and replaced them with static mesh and was not able to re-create the crash since. Brush geometry isn’t really geared to make a final level, its more so for the block out process of the level. Anyways the core elements of the BP work. Still have to figure out a way to make it so the grabbed item doesn’t go through walls.

Well even with Simulated Physics turned off couldn’t you keep custom collision settings so that it would collide with world static, world dynamic… so on and so forth?

It does, as seen by the fact that it hits the other boxes. But it cannot move a wall, and because of that the transform takes priority and moves the object inside the wall regardless of collision setting. What I was thinking is having the Contact Point trigger hit events with object collisions of type Static World. So that when the Contact Point hits a Static Object, it releases the object that the gravity gun is carrying. I will try this later tonight, unless you guys figure it out first :slight_smile:

My apologies for the late response.

Is there a reason that nothing is plugged into the In Socket Name element of the Get Socket Transform node? I’ve had no luck so far getting it to work. Any ideas?

Hi Chronozoah,

Here’s a semi-official tutorial on picking up objects and launching them: A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums

Just intensify the impulse a bit and there you go!

Let me know how that goes for you.

The Socket name looks for a string. In this case we didn’t need it because the node gets the transform information directly from the socket target that we give it. I’m not sure why it isn’t working for you. Make sure that the world setting are set to look for the proper game mode and that the game mode uses the proper character blueprint.

That’s…a large set-up there, heh.

I’ll work through it properly tomorrow, but from messing around with the blueprint earlier I already encountered some issues. Are there specific, important pre-requisites that this tutorial assumes are in place?

Also, could this be an issue between versions? I’m working with 4.3 (as per the requirements of my University module at present), but the article you linked specifically draws attention to the fact that it was made functional within the confines of 4.5.

Hm.

What is the cause of those error messages? You and I both seem to have them in the same places.

All of the features being used in the tutorial were already available in 4.3, so it is possible to get it running.

Some of the node’s names may have changed or the workflows may be a little different, so let me know if there are any inconsistencies and I will be happy to update with guide and add notes for different versions.

That was my concern. I’ll be on the lookout for those possible inconsistencies when I get back to the project.

Thanks.

Any reason why it makes object that are picked up bigger? Or a way to get around this?

Same as sgtfluffybutt, my object seems to scale. The scripting works! but I don’t know why the object keep scaling. Please let me know if a solution to this is found.