x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to make a pawn move physics objects

Hey! I'm new to Unreal Engine, an I'm currently working on a top-down shooter project. I'm using a Pawn with the Floating Pawn Movement component, and the movement is handled by add movement input. Although, the pawn can collide with other physics objects but it can't move them. If I attach any collision component as the root, it interacts with the physics objects. Is there any way that I could make the pawn move the objects?

Any help is appreciated!

Thanks!

Product Version: UE 4.12
Tags:
more ▼

asked Jul 06 '16 at 11:57 AM in Blueprint Scripting

avatar image

werockpokey
49 2 3 5

avatar image Krxtopher Jul 06 '16 at 01:02 PM

What exactly do you mean by "the pawn can collide with other physics objects but it can't move them." How do you know it's colliding if it isn't moving them? Also, can you tell us what the "Collision > Collision Preset" value is set to for both your pawn and the objects you want it to move?

avatar image werockpokey Jul 06 '16 at 01:09 PM

The collision preset for the pawn is "Pawn", while for the other objects it is "PhysicsActor". I know they are colliding because my pawn hits the object and just moves along them, instead of displacing them.

avatar image Prithvi Singh Jul 06 '16 at 01:37 PM

are they simulating physics?

avatar image werockpokey Jul 06 '16 at 01:58 PM

The objects, yes. The pawn, no. And turning the option to true for the Pawn doesn't change anything.

avatar image Krxtopher Jul 06 '16 at 01:48 PM

I don't encounter this problem when I use the characters included in the First Person or Third Person templates. Can you provide steps for us to recreate the pawn you've created?

avatar image Prithvi Singh Jul 06 '16 at 01:52 PM

neither i encounter any problem. but in question he mentioned floating pawn movement.

i guess he is using something related to flying templates.

avatar image werockpokey Jul 06 '16 at 01:57 PM

Okay, so... I started off with the TwinStick Project. I added the Floating Pawn Component to the TwinStickPawn that comes with it. (I removed all the stuff that was in the event graph) I created a controller to handle the rotation using the mouse, and the movement using the WASD keys. The pawn doesn't simulate physics and even if I turn that option on, it doesn't affect the behavior. Is it something to do with the AddMovementInput? Because in my other projects I have used AddForce and it allows me to properly interact with the objects, but in this one, it isn't. It is as if the AddMovementInput is not allowing the Physics to work properly.

avatar image Prithvi Singh Jul 06 '16 at 02:00 PM

i meant the objects it's collidng with must simulate physics

avatar image werockpokey Jul 06 '16 at 02:01 PM

Yeah, they are simulating physics

avatar image Prithvi Singh Jul 06 '16 at 02:05 PM

are you talking about the yellow boxes in the level?

avatar image werockpokey Jul 06 '16 at 02:06 PM

Yes.Those. It can be easily verified by shooting the projectile at them...

avatar image Prithvi Singh Jul 06 '16 at 02:12 PM

they require impulse to move

avatar image Prithvi Singh Jul 06 '16 at 02:13 PM

the projectile in twin stick shooter had impulse feature

avatar image werockpokey Jul 06 '16 at 02:14 PM

Yes. But shouldn't the pawn be able to move them as well? If we set the Pawn to simulate physics, and then use addForce to move it around, it will displace the boxes. But I don't want to use that method as it doesn't allow me to have much control over the Pawn's movement as compared to the Floating Pawn Component...

avatar image Prithvi Singh Jul 06 '16 at 02:17 PM

just do the below steps it will (increase the impulse )

avatar image Prithvi Singh Jul 06 '16 at 02:15 PM

just do this
alt text

zparameter5.jpg (307.3 kB)
avatar image Prithvi Singh Jul 06 '16 at 02:16 PM

also enable generate hit events in your pawn

avatar image werockpokey Jul 06 '16 at 02:21 PM

Okay. I tried it, and although it is able to move the boxes, it isn't the behavior I was looking for. (^_^)' See, what I want is something similar to what happens when that Pawn would actually hit the box. I.e., instead of applying a constant impulse to the boxes, they would move as if a force had been applied to them by the Pawn. You can simulate the behavior which I'm talking about by using AddForce on the Pawn to move it around and then hit the boxes with the pawn.

avatar image Prithvi Singh Jul 06 '16 at 02:22 PM

it is possible ...wait let me try

avatar image Prithvi Singh Jul 06 '16 at 02:25 PM

do this
alt text

zparameter5.jpg (330.4 kB)
avatar image werockpokey Jul 06 '16 at 02:26 PM

Okay, I'll give it a shot. Meanwhile, can you please try the AddForce method?

avatar image Prithvi Singh Jul 06 '16 at 02:27 PM

ok..i will

avatar image werockpokey Jul 06 '16 at 02:35 PM

I tried it, and it seems like it will only add an impulse in the direction the Pawn is facing. And it's actually kinda glitchy as we move the pawn around. Any luck with the AddForce method?

avatar image werockpokey Jul 06 '16 at 02:42 PM

Okay, so, I replaced the ForwardVector by the Velocity, and it fixes things a bit. It can be used, but it's still a workaround. I still would like to use a more physics based approach though.

avatar image Prithvi Singh Jul 06 '16 at 02:49 PM

i was unable to make out how exactly you are using the add force , mind sharing a pic of BP? and make sure enable gravity is off(make it fly) . i am getting satisfying results like that.

avatar image werockpokey Jul 06 '16 at 03:06 PM

AddForce works fine for me as well. And that's the behavior I want to use! And that's what the problem is with AddMovementInput. The collisions don't behave properl with it, while they do with AddForce.

The reason why I don't want to use AddForce is the lack of control there is. Also, when I use the mouse rotation, it doesn't work properly due to the torque being applied to the Pawn by external forces/impacts.

avatar image Krxtopher Jul 06 '16 at 04:33 PM

werockpokey, you're right to insist on a solution that doesn't rely on AddForce. You shouldn't have to use AddForce to get what you want as is in evidence by the characters in the First Person and Third Person templates which behave exactly as you describe. There's definitely something we're overlooking. Would you mind sharing screenshots of your PlayerController and Pawn event graphs so we can more easily recreate your scenario?

avatar image Prithvi Singh Jul 06 '16 at 04:40 PM

even rolling template proves there is no need for add force(even impulse)

avatar image werockpokey Jul 06 '16 at 06:01 PM

I just checked out the Rolling template, and in that template, they are adding torque to the ball to control the motion. It is also a physics based approach to movement, and in this case, it is justified as well.

avatar image werockpokey Jul 06 '16 at 05:44 PM

I'll just share the screenshots of them...

I guess in the First and Third person blueprints, they have a collision component, and they use a Character class for the pawns. Also, if I add a collision as the root in my pawn, the collisions work properly, but the physics doesn't. I mean, I can easily move a 10000 Kg block with my pawn!! Which is not even close to possible had it been a proper physics collision. It would require the pawn to collide at a very very high speed with the block. So, setting a collision as the root is also out of the window...

controller.jpg (421.1 kB)
pawn_eventgraph.jpg (487.6 kB)
avatar image werockpokey Jul 06 '16 at 06:45 PM

@Krxtopher, as you said, I also checked the First and Third person templates, and they do exactly what I want. But in my project, even when I choose the Pawn to inherit from Character class, it doesn't behave the same way as the characters do in the first and third person templates.

I'm totally outta options, and I can't understand what to do... :(

avatar image werockpokey Jul 06 '16 at 03:12 PM

Also, if I'm not wrong, the physics simulation depend on the frame rate, right? If that's the case then I don't think I'll be using AddForce for controlling the pawn.

avatar image Prithvi Singh Jul 06 '16 at 03:18 PM

what results are you getting pls share a photo of it. (ctrl+prtscn)

avatar image werockpokey Jul 06 '16 at 05:46 PM

With addForce, everything works fine. But as I said, I don't want to use this approach.

avatar image werockpokey Jul 06 '16 at 07:51 PM

Sorry for posting so much, but I'm just a bit too curious about this thing (^_^)"

Observation: In character pawns, there is a property under the Character Movement component that is: Character Movement: Physics Interaction, and it has a lot of stuff pertaining to the behavior which is seen in the First Person and Third Person templates. Also, if any part of the character's mesh is outside the Capsule Collision, the physics of the collisions go haywire. Thus, any part which needs to have proper physics based collisions have to be inside the Capsule.

From what I have seen until now, that's the only way by which I can justify how those Characters have proper collisions. But then, again, those are Characters, and not basic Pawns.

I hope this can help you guys to help me out!

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

TL; DR: For a Pawn to have proper physics interactions/collisions, all that is required is proper handling of the hit events via physics forces.

Hey Prithvi, First of all, thanks a lot for giving your valuable time. I really appreciate it!

I went through the links you provided and it did help me understand a bit more about collisions.

Although we couldn't reach to a solution to the main problem, it did make me understand what was going on.

As Krxtopher pointed out that the physics interaction was proper in other templates involving character components, and the method you provided via blueprints, I came to a conclusion that all I need for the proper interaction was to create either: 1: A custom movement component via code or, 2. Implementing the OnComponentHit behavior in the Pawn's blueprint

I guess, I'll give both of these a shot. Also, I looked into this answer https://answers.unrealengine.com/questions/303853/making-custom-pawn-physics.html and then, into the Character Component's cpp file, and I believe that all the Character Components use ApplyForce and ApplyImpulse for the physics simulation, and to handle hit events.

So, as far as my knowledge goes, that's probably the only way to make a non-physics pawn interact with other physics bodies.

more ▼

answered Jul 07 '16 at 04:13 PM

avatar image

werockpokey
49 2 3 5

avatar image werockpokey Jul 07 '16 at 06:57 PM

I'll mark this as solved for now. Thanks a lot guys for pointing me in the right direction

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question