How to attach an actor to other actor without using "AttachActorToActor" node?

Hi, currently i have an object that i can grab and ungrab by using “AttachActorToActor” node but this method doesnt use the grabbed actor collisions and this is a problem because the object when grabbed overlaps everything else on the level and the player can ungrab it in anywhere causing wierd overlaps and even gamebreaking bugs.

To be more specific it is a big object that the player drags around the level to unlock hidden passages, (the player doesnt actually grabs if you catch me), because of that i dont want it to overlap walls etc… Using the “AttachActorToActor” the object loses collisions and only the player capsule component works as collision.

Do you know other method for this effect or know how to perserve actors collision when using “AttachActorToActor”?

Thank you in advance

Maybe you don’t actually want to attach the actor? Maybe you want to attach a physical constraint, that will apply some force on the “grabbed” objects, when it’s too far from where it should be? And some friction to make it slow down when the force is low.

Another option is to harvest the components from the object, and attach them to yourself instead. Once you want to let go, move the components back. You might be best off using a specific “scene” component on yourself that’s always the parent of attached other-components, so they’re easy to find.

Finally, do you set bWeldSimulatedBodies when calling AttachToActor()? I haven’t checked whether the “collision shapes transfer” matters there. But, also, if the actor you’re attching to is a Character, then a Character will only really pay attention to the main capsule it collides with, it won’t run rigid body simulation on the other actor – so you’d need a constraint, or some other physical means to move the other actor around.

1 Like

I will try to do that coinstraint option thanks :slight_smile: And yes i used WeldSimulatedBodies option, tried with fals and true and no significant changes, dont actually know what that does

If the main actor is a character, it probably doesn’t do anything, because character movement is only vaguely physical.

For a fun time, try building your own character controller that’s based on moving a capsule around using only physical forces and torques sometime. You can do some fun stuff, but there are also a bunch of special cases that don’t work well (running downhill being a common one.)

Hi, i kinda fixed this problem using a physics handle, but now if the object collides with a obstacle it stops like it should but the player keeps moving while remaining in the grab state.

How to make the player plawn stop if the grabbed object hits an obstacle, for example: imagine i have a box that is bigger than my door opening and im walking backwards when i try to pass through the door with the box the box gets blocked but the player pawn keeps moving even tho the box is blocked and
still in the grabbed state, how do i prevent the player from moving in this situation (if the box gets blocked)?

this box is “grabbed” but got blocked by the couch still the player kept moving and i want to prevent this

for better understanding check this dog video at 0:21

this is what I am trying to replicate

The Unreal character movement controller is not physical. It’s made to make for robust, fun, FPS-style movement of a character, that works well on a network.

If you need physical simulation for a character, you can do one of two things:

  1. Add hacks. For example, sense when the carried object hits something, and force the capsule to stop and move back to its previous position.
  2. Write your own character movement controller (or perhaps just movement mode for the character controller.) This should use physical movement – brake with friction and damping, turn with torque, and move with force. Maybe add a constraint to make sure it stays upright.

Option 1) almost always leads to tears, although you can whack that square peg into that round hole enough to ship a game. Option 2) is a lot of work to get good, solid, robust, but it works much better in physics-based games.

1 Like

Tried to use unreal character movement to simulate physics, it wasn’t good at all, so I decided to make my own movement, I spent maybe two months in total, but now I’m almost satisfied

@Lorenze
How have you done that? dou you know any tutorial? im not very good at coding

Do you know what nodes should I use to force the player pawn to go to a certain location even if the locomotion keys (ASWD) are being pressed?

I used this but doesnt seem to work:

So, as jwatte said - there are two ways and both have pros and cons.
My game is about spaceship battles. Started with character movement, tried several others, spent a lot of time simulating physics :smile:
In my case, I have to make my own physics-based movement because otherwise it is nearly impossible or it will cost even more. I made it based on physics thruster, it works much better than it was before with non-physics movement.
In your case, you need to choose your own way, I can’t give you a piece of good advice about your project but what I can say - just do different things and you will get experience. I wasn’t good at coding at the start and still have a lack of expertise but now I am able to do much more complicated things, just don’t give up

If you want to “take away control” from the character, then you need to add a “PlayerInControl” boolean to the class that reads input commands, and switch each Event Input xxx based on whether this is set or not.

If you want to teleport the player to some other location, SetActorLocation can work, but you should check the “teleport” checkbox.

If you want to move the character around in a custom way, you’re better off building a custom movement mode for the CharacterMovementComponent. You can learn more in the docs, although you have to go pretty deep:

Note that Character is specifically to support a player character in a typical FPS or TPS game. If you need something else – vehicles, space ships, and so on – don’t use Character! Use a Pawn (subclass APawn) and add your own movement behavior. You can turn on “simulates,” give it mass and collision geometries, and make the player controller add forces/torques to the body to move it around.

What the Character gives you is things like “tries hard to stay glued to the floor,” and “networked replication with smoothing,” and “can jump/crouch/animate as a human person.” But anything else can add a Skeletal Mesh Component and an Animation Blueprint for that same mesh just fine, and build the behaviors they need, just based off of Pawn. Character is a helpful utility, but it’s not “Magic” and it’s pretty hard-coded to do what it does.

2 Likes