Physics Constraint Hitch-able Trailer
Here to use Driving Chaos Vehicle Projects to make hitchable trailer
Import Mesh and Texture: Crab the model and texture into Browser
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
WheeledVehiclePawn
Create BP:
Right click mouse > Blueprint Class
All Classes:
search: vehicle
Select “ WheeledVehiclePawn ”
Mesh > Skeletal Mesh Asset > trailer
Wheel Setup
Select Vehicle Movement Component
This trailer has two wheels so Press 2 times to add
Wheel Setup > Wheel Setups > +
Go to Skeleton and copy bone name
Select the bone > right click > Copy selected Bone Names
Paste to Wheel setups index bone name
Turn on Simulate Physics
Trailer Physic
Open physics Asset
Select physic and delete
Because the default physic shape is not fit for the trailer
Select wheel bones > Primitive shape: Sphere >Add bodies
Select Root bone > Primitive shape: Single convex Hull >Add bodies
Input Action
Project settings
Go to Engine - Input
Action Mappings: Interact--> T
Animaton
Obtain the behaviors we want for our vehicle.
Select trailer skeleton > right click mouse > Create > Anim Blueprint
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.
GO to BP_trailer
Select Mesh > Animation > Anim Class : ABP_trailer
Prepare Interaction Object
Open BP_CAR
Add Collision, and naming: Docking.
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.
Functions: Interact
Inputs: car (BP_Car, object reference)
Open BP_car
Use for loop to check does implement interface, if true, does interact
Opne BP_Trailer
Add Collision
Naming: Trigger_coli
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.
Constraint
Conponent name 1: Mesh
Conponent name 2: Trigger_coli
Control Physics constraint - Angular Limits
Swing 1 motion (Z) : Limited, swing 1 limted: 60
Swing 2 motion (x): Locked
Twist motion (y): Locked
Add Text Render
1. Text: type the information.
2.Turn off visibility
Add cube
In order to let trailer to stand on the ground, so add cube
Add Interface
Class Settings > Implemented Interfaces > select BI_Interact
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
When begin overlap, try Hitch: turn on
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
Set text visibility and delay the time.
After completed, try hitch again to condition, if true, cast to bp_Car
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
Result:
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
Event graph
Using event tick to do event StandRemoved.
If stand is valid, remove stand. If not, do once to print string
Event Interact:
Remove stand event and turn off standRemovedbool
Result:
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
BuyMeAcoffee: https://www.buymeacoffee.com/lutopialab
Patreon: https://www.patreon.com/LutopiaLab/
#ChaosPhysics #car #UnrealEngine5 #教學 #虛幻引擎 #車子#Vehicle #Drive #PhysicsConstraint #可掛接拖車 #HitchableTrailer
Opmerkingen