top of page
Search

[Chaos Physics] Unreal Engine 5.2 物理約束可掛接拖車車輛教學 |Physics Constraint Hitchable Trailer

  • Writer: Liling Liu
    Liling Liu
  • Nov 17, 2023
  • 3 min read


Physics Constraint Hitch-able Trailer


ree


Here to use Driving Chaos Vehicle Projects to make hitchable trailer

 

Import Mesh and Texture: Crab the model and texture into Browser


ree




ree

Trailer already rig and skin

 

FBX import Options:

Skeletal Mesh: turn on

 

Combine Meshes: If you have many separate mesh, you could turn on














Plugins:

 

ChaosVehiclesPlugin

ree


WheeledVehiclePawn

 

Create BP:

 

ree

Right click mouse > Blueprint Class

 

All Classes:

search: vehicle

Select “ WheeledVehiclePawn ”



ree

Mesh >  Skeletal Mesh Asset > trailer


ree


Wheel Setup

 

Select  Vehicle Movement Component

 

This trailer has two wheels so Press 2 times to add

 

Wheel Setup > Wheel Setups > +


ree

Go to Skeleton and copy bone name

 

Select the bone > right click > Copy selected Bone Names

 

 

ree

 

 Paste to Wheel setups index bone name

ree

Turn on Simulate Physics


ree

Trailer Physic

 

Open physics Asset

ree

Select physic and delete

 

Because the default physic shape is not fit for the trailer


ree

Select wheel bones > Primitive shape: Sphere >Add bodies


ree

Select Root bone > Primitive shape: Single convex Hull >Add bodies


ree

Input Action

 

Project settings


ree

Go to Engine - Input

ree

Action Mappings: Interact--> T


ree

Animaton

 

Obtain the behaviors we want for our vehicle.

 

Select trailer skeleton > right click mouse > Create > Anim Blueprint

ree


Opne AnimBP > Class Settings > class options > Parent Class : Vehicle Animation Instance

 

 

Mesh Space Ref Pose: this is used to return the mesh space reference pose for our skeletal mesh in the Animation Blueprint

 

Wheel Controller : offloading a lot of the work in creating these types of animations, you can use the Wheel Controller Node to drive the animations.


ree

GO to BP_trailer

 

Select Mesh > Animation > Anim Class : ABP_trailer


ree

Prepare Interaction Object

 

Open BP_CAR

 

Add Collision, and naming: Docking.

ree


Blueprint > Blueprint Interface

 

A Blueprint Interface is a collection of one or more functions - name only, no implementation - that can be added to other Blueprints. This is essentially like the concept of an interface in general programming, which allows multiple different types of Objects to all share and be accessed through a common interface.


ree

Functions: Interact

Inputs: car (BP_Car, object reference)


ree

Open BP_car

 

Use for loop to check does implement interface, if true, does interact

ree

Opne BP_Trailer

 

Add Collision

 

Naming: Trigger_coli

ree

Add PhysicsConstraint

 

A physics constraint is a joint that allows you to connect two Actors or component together and also apply limits or forces on them.


ree

Constraint

Conponent name 1: Mesh

Conponent name 2: Trigger_coli

 

ree

Control Physics constraint - Angular Limits

 

Swing 1 motion  (Z) : Limited, swing 1 limted: 60

Swing 2 motion (x): Locked

Twist motion (y): Locked

ree

Add Text Render


ree


1. Text: type the information.

2.Turn off visibility

ree

Add cube

 

In order to let trailer to stand on the ground, so add cube

ree

Add Interface

 

Class Settings > Implemented Interfaces > select BI_Interact


ree

Add variables:

1. CanHitch :Boolean

2. TryHitch : Boolean

 

Select trigger_collision box add begin overlap and end overlap

 

When End overlap,  try Hitch: turn off, and text does not show

ree

When begin overlap,  try Hitch: turn on

 

ree

Get  car docking and trailer trigger_coli’s world location and do float to integrate value

Does car docking X subtract trailer trigger X to get the value. The value is less equal what we want the value. However, we might be get the negative value, so here I use ABS to get positive value.

 

Does car docking Y subtract trailer trigger Y to get the value. The value is less equal what we want the value.

 

X and Y value both are true and return true.

Set true/false to can Hitch

ree

Set text visibility and delay the time.

After completed, try hitch again to condition, if true, cast to bp_Car

ree


Interact Event

 

If can hitch, the car connect to trailer to get movement and set constraint components. Turn off try hitch and set text visibility.

Otherwise, when press T again, release the throttle and break constraint, and  set try hitch: turn on

ree

Result:


ree

Stand

 

When the car connects into the trailer, the stand is disappear.

 

 

Creat function: RemoveStand

Add Variables: StandRemovedBool :bool

Open RemoveStand function:

Destory stand compoent, and set standRemovedBool: on, and call stand removed


Event Dispatchers: StandRemoved

ree

Event graph

 

Using event tick to do event StandRemoved.

If stand is valid, remove stand. If not, do once to print string


ree

Event Interact:

Remove stand event and turn off standRemovedbool

 

ree

Result:

ree





Youtube Tutorial:






Plugins: ChaosVehiclesPlugin

 

 

Sketchfab  -  Car Scene:

 

Sketchfab  - Generator Trailer:

 

 

Physics Constraint Component:

 

 

 

How to Set up Vehicles Unreal Engine 5.0

 

Ref: Unreal Engine Truck Tutorial: Trailer System



教學專案和文件下載 /  Full Project and Document Download:

 

 

  

贊助 / Support Me

 

 

 















 
 
 

Comments


CONTACT

Liling Liu

Email: liling5731@gmail.com

© 2016 - 2025 by LilingLiu. All rights preserved.

bottom of page