top of page
搜尋

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

  • 作家相片: Liling Liu
    Liling Liu
  • 2023年11月17日
  • 讀畢需時 3 分鐘

物理約束可掛接拖車車輛


ree


在這邊使用 Driving Chaos Vehicle 專案來製作掛接拖車

 

匯入模型和貼圖: Crab the model and texture into Browser


ree




ree

拖車已經有綁訂了

 

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

 

選擇  Vehicle Movement Component

 

這個拖車有兩個輪子,所以按兩次+ 增加

 

Wheel Setup > Wheel Setups > +  


ree

到骨頭檔案並複製骨頭名字

 

選上骨頭 > 右鍵 > 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

 

因為預設的物理形狀不符合拖車


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

準備互動物件

 

Open BP_CAR

 

增加碰撞體 ,命名為 Docking.


ree


Blueprint > Blueprint 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

 

物理約束是一個關節,可讓您將兩個 Actor 或組件連接在一起,並對它們施加限製或力。


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

 

如果可以掛接,則汽車連接到拖車且移動並設置約束組件。 關閉嘗試掛鉤並設定文字可見性。

 

否則,當再次按下T時,釋放油門並打破約束,並設定嘗試掛接:打開


ree

Result:


ree

Stand

 

當汽車連接到拖車時,支架就會消失。

 

 

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.

如果支架有效,請移除支架。 如果沒有,則執行一次列印字串


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

 

 

 















 
 
 

留言


CONTACT

Liling Liu

Email: liling5731@gmail.com

© 2016 - 2025 by LilingLiu. All rights preserved.

bottom of page