Some Tips to Using Physics in Unreal Engine 4


For this post, I have Peter L. Newton, a game developer and VR developer, to talk about some of the issues that you might encounter when dealing with physics for Unreal Engine 4 (UE4).


What’s Up Everyone,

This is Peter L. Newton, thanks for joining me today! Welcome to an edition of Things I Wish I Knew When Starting In UE4. Because tell me how often have you had a problem resolved with a checkbox? I hope I can show you a gem of checkboxes. I also want to take this opportunity to shout out Steven for what he is doing at Bright Developers and show him how much I appreciate him allowing me to contribute. I look forward to future post! So…let’s go!

 

Do you Physics?

If you’re constantly in a state of working, it can sometimes be easy to forget the basics. And those like me who rely heavy on the Editor, the screen can start to blend together after a long day or just getting frustrated. I found that me and some colleagues at work where having some difficulties with getting Physics right. I also notice we kept running into a lot of the same issues, which I found others also came across.

 

TL;DR

So I’ve compiled a list below which highlights some of the gotcha’s with Physics behavior within Unreal Engine 4.

 

Mesh Components Properties (Static Mesh or Skeletal Mesh)

 

Mesh Component Collision must be enabled, but the Collision Response can be anything.

This is all that is required for physics to work as expected. Notice: You can ignore everything and still simulate.

Check that Collision primitives (Custom Collision, etc) exist on the mesh component.

This is within the Mesh Asset. This information draws in the top left of the viewport. Notice: Num Collision Primitives has to be more than 1 for physics to behave as expected.

Don’t negatively scale mesh component, breaks internal collision.

An example of what not to do.

Physics Properties (Getting, Setting)

 

Setting improper mass of objects can break collision internally.

An example of what not to do.

Static Mesh Collision Complexity must be SimpleAsComplex for normal physics behavior, ComplexAsSimple allows colliding with Physics simulating actors but you cannot simulate the component.

This is how you set your Collision Complexity on your Static Mesh Asset.

Request For or Do Work at the appropriate time. Set Mesh before Event Begin Play on that actor, Request mass after object is in world simulating. Mass Scale works before Event Begin, Get Mass / Set Mass doesn’t.

Use this Event Begin Play(post-physics state) or Construction Script(pre-physics state) as places to begin before or after Physics begin.

Body Instance contains Physics Properties of Mesh Components.

This is a lot of properties; at your command.

Physics Behavior

Simulated Mesh Components do not have parents, only children. Use Physics Constraints as a replacement of the normal Scene Component hierarchy. Don’t rely on Set Actor Location unless the Mesh Component is the root of the Actor.

Physics constraints allow constraining two simulated, or one simulated mesh component to another.

 

And that is it! This list isn’t exhaustive but I hope it points out some of the gotcha’s that got me during my time with Physics!

 

Till next time,

Peter L. Newton

http://peterlnewton.com/

 


About Steven To

Steven To is a software developer that specializes in mobile development with a background in computer engineering. Beyond his passion for software development, he also has an interest in Virtual Reality, Augmented Reality, Artificial Intelligence, Personal Development, and Personal Finance. If he is not writing software, then he is out learning something new.