I am making a 3D side platformer. The player (character class) is a cube and I would like the cube to follow the shape of the terrain and still be able to control the cube. Something like this:
Here is my current blueprint structure:
What I’ve tried:
- Enable “Simulate physics” on the static mesh (MeshComp), but it causes the cube to ‘detach’ from my character. The cube respects the physics, but does not move by key presses anymore. (I can only control an invisible entity and push the cube around)
- Stick the CapsuleComponent and the static mesh together using a PhysicsConstraint and adjust its properties.
- Wrapping CapsuleComponent inside a PhysicsConstraint to affect all children.
- Remove the default SkeletalMeshComponent
These didn’t seem to work. Do you guys have an idea on how I could make it work?
The thing at the bottom that says CharacterMovement, that’s non-physics based movement. If you want physics based movement, you’re going to have to create a blank pawn and code it yourself from scratch.
This video gives you a little introduction on how to do that Pawn Blueprints - #16 Unreal Engine 4 Blueprints Tutorial Series - YouTube
Okay so now I’ve recreated my character from a fresh Pawn subclass. Do I need to enable physics and gravity on any of my components or do I need to code the collision and physics in order to calculate to cube’s rotation?
When I enable physics, collisions work but I lose control of the cube.
Here is my current blueprint:
yes you need to simulate physics on the Mesh Component.
This is the part where you have to code the movement yourself. If you right click and uncheck ‘Context Sensitive’ and scroll down to Physics, you will see all the options they’ve given you.
If you don’t want your cube to spin wildly, in the mesh details find “Max Angular Velocity”, check that box and set it equal to zero.
Here’s a tutorial on how to create a hover vehicle that helped me out when i first started [Unreal Engine 4.7+] Hover Vehicle Blueprint Tutorial - YouTube
I am using a C++ based blueprint. I tried to replicate the video in C++ with no success.
Here is a visual of the “detachment” I was referring to: https://i.imgur.com/5T4fSMX.mp4
How can I stick my mesh and box components together?
Okay it works now! I simply inverted MeshComponent and BoxComponent in the blueprint. Thank you for your precious help!