How can i push to an object to a wall or a surface in front of me while holding. Like gravity gun using mouse wheel to change its distance ?

I am working on a project to improve my unreal engine skills. As you can read from the topic i need to make pushing mechanism to holding objects. To be honest i tried most of ways to make it happen but im kinda new to this engine.

Imagine a holding object with like gravity gun or just some kind of powers and i want to send object to the surface in front of me but no clipping, must be offset based on object size. I dont know if im clear or not.

Can you give some tips?

1 Like

Hey there @JarmenK! Welcome to the community! Here’s a tutorial to do the full gravity gun. Please let me know if you have any questions:

Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.

i am so thankful for sending this video to me, but how can i push the object without pressing anything, as long as i am holding the object i want to push that object to line trace end point without clipping? Where ever i look i want that object to that surface like surfing on the wall or sth? Thank you again.

when i try to move the component to where i look (i mean where my line trace end), it staying in weird position not based on line trace.

here is the blueprint.

Can you show the code of ‘vector’?

It’s just a simple trace vector event.

Had to check. Many people get it wrong.

I think your problem is, the line trace is in world space, but move component to, is relative.

You can convert from world to local

it didn’t work :frowning: nothing happened,object stand still when i hold. I’m in BP_FirstPersonCharacter btw. Should i use different transform for this because it’s targeting “self” ?

You need to say what to move

:flushed: you’re right, my bad. But still it doesn’t work somehow. the object trying to go somewhere in the scene when I hold it. I don’t know which specific point. It doesn’t seem complicated but I don’t know what I am missing.


Couple of things:

  1. Have you got physics enabled on the cube?

  2. Because you have this on tick, it’s trying to reposition every frame. It might be an idea, for testing, to just call it when you click the mouse and wait to see where it’s going.

Instead of using ‘move component to’, if you’re doing it on tick, why not just use ‘set relative location’?

1- Yes, it is enabled for the cube.
2- Tried to do that when i press specific key (“b”). And set the player start top of the walls then it appears my little cube this time go to different direction but not to where i want it when i press the key.
3- And yes I tried to set relative location every tick but nothing changed.


Does the tutorial above, not cover everyting?

Unfortunately not :frowning: But!! I realized sth ! When I connect the “trace end” pin to transform node. Only that pin is giving true position of where I look but it always end when trace end obviously. I think I can’t convert the “impact point” pin properly to relative location. Because no matter what when i connect “impact point + transform” or just "impact point to location "combination are giving crazy things, object is flying somewhere. How can I properly convert the end point pins ? Hmm…

I don’t really know your setup. Have you tried without physics? What’s wrong with the tutorial?

Nothing wrong. Just different subjects.

Ok, so what is your setup? You have a physics enabled cube, but also a handle, or socket or? What else? :slight_smile:

Physics enabled objects, a physics constraint component with static mesh object slot. When Player hold the object,object is placed in static mesh object slot then setting constrained component with component one : “object slot” and component 2: “hit object component” to targeting physics constraint.