Passer au contenu principal
Version: latest - a1.172.0 ⚖️

Base Vehicle

Base class for all Vehicle entities

👪Base Class🧑‍💻API Source
👪Base Class
This is a Base Class, an abstract definition that shares common methods and events with it's child classes. You cannot spawn it, and you cannot call anything on the Base Class name itself. Use any class that inherits it.

Classes that share methods and events from this Base Class: VehicleWheeled, VehicleWater.

🦠 Fonctions​

Animation
BindAnimationBlueprintEventDispatcher: functionAssigns and Binds an Animation Blueprint Event Dispatcher
CallAnimationBlueprintEvent: varargs of anyCalls an Animation Blueprint Event or Function
GetAnimationBlueprintPropertyValue: anyGets an Animation Blueprint Property/Variable value directly
PlayAnimationPlays an Animation on this Vehicle
SetAnimationBlueprintPropertyValueSets an Animation Blueprint Property/Variable value directly
StopAnimationStops an Animation Montage on this Vehicle
UnbindAnimationBlueprintEventDispatcherUnbinds an Animation Blueprint Event Dispatcher
Appearance
GetMesh: SkeletalMesh ReferenceGets the Asset name
HideBoneHides a bone of this Vehicle
IsBoneHidden: booleanGets if a bone is hidden
UnHideBoneUnHide a bone of this Vehicle
Attachments
AddSkeletalMeshAttachedAttaches a Skeletal Mesh as master pose to this entity
AddStaticMeshAttachedAttaches a Static Mesh to this entity
GetAllSkeletalMeshAttached: table of stringGets all Skeletal Meshes attached to this entity
GetAllStaticMeshAttached: table of stringGets all Static Meshes attached to this entity
RemoveAllSkeletalMeshesAttachedRemoves all SkeletalMeshes attached
RemoveAllStaticMeshesAttachedRemoves all StaticMeshes attached
RemoveSkeletalMeshAttachedRemoves, if it exists, a SkeletalMesh from this Vehicle given its custom ID
RemoveStaticMeshAttachedRemoves, if it exists, a StaticMesh from this Vehicle given its custom ID
SetStaticMeshAttachedTransformSets a Static Mesh Attached location and rotation
Handling
IsEngineStarted: booleanChecks if the engine is started
SetCameraArmLengthSets how far the camera stays from this Vehicle while driving it
SetCameraOffsetSets the Vehicle Camera Offset
Passengers
GetDoors: tableGets all configured Doors
GetPassenger: CharacterGets a passenger from a seat
GetPassengers: table of CharacterGets all passengers
SetDoorAdds a Door to the Vehicle
Physics
SetBuoyancyPontoonsSets the Buoyancy Pontoons used by the Water simulation
SetBuoyancySettingsSets how this entity behaves on Water
SetExplosionSettingsConfigures the Explosion Settings when health reaches zero

Animationfunctions​

BindAnimationBlueprintEventDispatcherSlow​

Assigns and Binds an Animation Blueprint Event Dispatcher

Note: only VehicleWheeled has an Animation Blueprint, on any other Vehicle type this does nothing

local ret = my_vehicle:BindAnimationBlueprintEventDispatcher(dispatcher_name, callback)
Paramètres
NameTypeDescription
dispatcher_namestringEvent Dispatcher name
callbackfunctionCallback function to call with this format
Returns
TypeDescription
functionle callback lui-même

CallAnimationBlueprintEventSlow​

Calls an Animation Blueprint Event or Function

Returns all Function return values on Client Side

Note: only VehicleWheeled has an Animation Blueprint, on any other Vehicle type this does nothing

local ret_01, ret_02, ... = my_vehicle:CallAnimationBlueprintEvent(event_name, arguments...?)
Paramètres
NameTypeDescription
event_namestringNom de l'événement ou de la fonction
arguments...?anySequence of arguments to pass to the event Par défaut nil
Returns
TypeDescription
varargs of anythe function return values

GetAnimationBlueprintPropertyValueSlow​

Gets an Animation Blueprint Property/Variable value directly

Note: only VehicleWheeled has an Animation Blueprint, on any other Vehicle type this returns nil

local ret = my_vehicle:GetAnimationBlueprintPropertyValue(property_name)
Paramètres
NameTypeDescription
property_namestringName of the Animation Blueprint variable
Returns
TypeDescription
anythe property value

See also SetAnimationBlueprintPropertyValue.

PlayAnimationModerate​

Plays an Animation on this Vehicle

my_vehicle:PlayAnimation(animation_path, slot_name?, loop_indefinitely?, blend_in_time?, blend_out_time?, play_rate?, stop_all_montages?)
Paramètres
NameTypeDescription
animation_pathAnimation ReferenceThe Animation asset to play
slot_name?stringThe Animation Slot to play it on Par défaut DefaultSlot
loop_indefinitely?booleanThis parameter is only used if the Vehicle has an Animation Blueprint Par défaut false
blend_in_time?floatThis parameter is only used if the Vehicle has an Animation Blueprint Par défaut 0.25
blend_out_time?floatThis parameter is only used if the Vehicle has an Animation Blueprint Par défaut 0.25
play_rate?floatThis parameter is only used if the Vehicle has an Animation Blueprint Par défaut 1.0
stop_all_montages?booleanStops all running Montages from the same Group. This parameter is only used if the Vehicle has an Animation Blueprint Par défaut false

SetAnimationBlueprintPropertyValueSlow​

Sets an Animation Blueprint Property/Variable value directly

It is set on the Animation Blueprint passed in the constructor.

Note: only VehicleWheeled has an Animation Blueprint, on any other Vehicle type this does nothing

my_vehicle:SetAnimationBlueprintPropertyValue(property_name, value)
Paramètres
NameTypeDescription
property_namestringName of the Animation Blueprint variable
valueanyLa valeur à définir

See also GetAnimationBlueprintPropertyValue.

StopAnimationOptimal​

Stops an Animation Montage on this Vehicle

my_vehicle:StopAnimation(animation_asset?)
Paramètres
NameTypeDescription
animation_asset?Animation ReferenceLeave empty to stop all Montages Par défaut

UnbindAnimationBlueprintEventDispatcherOptimal​

Unbinds an Animation Blueprint Event Dispatcher

my_vehicle:UnbindAnimationBlueprintEventDispatcher(dispatcher_name, callback?)
Paramètres
NameTypeDescription
dispatcher_namestringEvent Dispatcher name
callback?functionOptional callback to unbind Par défaut nil

Appearancefunctions​

GetMeshOptimal​

Gets the Asset name

local asset = my_vehicle:GetMesh()
Returns
TypeDescription
SkeletalMesh Referenceasset path

HideBoneOptimal​

Hides a bone of this Vehicle

my_vehicle:HideBone(bone_name)
Paramètres
NameTypeDescription
bone_namestringBone to hide

See also UnHideBone, IsBoneHidden.

IsBoneHiddenOptimal​

Gets if a bone is hidden

local is_hidden = my_vehicle:IsBoneHidden(bone_name)
Paramètres
NameTypeDescription
bone_namestringBone to check
Returns
TypeDescription
booleanif the bone is hidden

See also UnHideBone, HideBone.

UnHideBoneOptimal​

UnHide a bone of this Vehicle

my_vehicle:UnHideBone(bone_name)
Paramètres
NameTypeDescription
bone_namestringBone to unhide

See also HideBone, IsBoneHidden.

Attachmentsfunctions​

AddSkeletalMeshAttachedSlow​

Attaches a Skeletal Mesh as master pose to this entity

Spawns and attaches a SkeletalMesh to this entity, the SkeletalMesh must have the same skeleton used by this Actor's mesh, and will follow all animations from it. Uses a custom ID to be used for removing/customizing it afterwards

🆕Updated Function
This method was recently updated in ver. 1.144. See the Versions de compatibilité page for more information.
my_vehicle:AddSkeletalMeshAttached(id, skeletal_mesh_path, socket?, relative_location?, relative_rotation?, use_parent_bounds?, use_base_leader_pose_component?, animation_path?, attachable_id?)
Paramètres
NameTypeDescription
idstringUsed further for removing or applying material settings on it
skeletal_mesh_pathSkeletalMesh ReferencePath to SkeletalMesh asset to attach
socket?stringBone socket to attach to Par défaut
relative_location?VectorRelative location Par défaut Vector(0, 0, 0)
relative_rotation?RotatorRelative rotation Par défaut Rotator(0, 0, 0)
use_parent_bounds?booleanIf true, this component uses its parents bounds when attached. This can be a significant optimization with many components attached together Par défaut true
use_base_leader_pose_component?booleanIf true, this component will use the base leader pose component for copying its animation Par défaut true
animation_path?Animation ReferencePath to Animation asset to play on the Skeletal Mesh attached Par défaut
attachable_id?stringOptionally attaches this to another attached skeletal mesh (instead of attaching to the root component) Par défaut

See also RemoveSkeletalMeshAttached.

AddStaticMeshAttachedSlow​

Attaches a Static Mesh to this entity

Spawns and attaches a StaticMesh to this Vehicle in a Socket with a relative location and rotation. Uses a custom ID to be used for removing/customizing it afterwards

my_vehicle:AddStaticMeshAttached(id, static_mesh_path, socket?, relative_location?, relative_rotation?, use_parent_bounds?, attachable_id?)
Paramètres
NameTypeDescription
idstringUnique ID to assign to the StaticMesh
static_mesh_pathStaticMesh ReferencePath to StaticMesh asset to attach
socket?stringBone socket to attach to Par défaut
relative_location?VectorRelative location Par défaut Vector(0, 0, 0)
relative_rotation?RotatorRelative rotation Par défaut Rotator(0, 0, 0)
use_parent_bounds?booleanIf true, this component uses its parents bounds when attached. This can be a significant optimization with many components attached together Par défaut true
attachable_id?stringOptionally attaches this to another attached static mesh (instead of attaching to the root component) Par défaut

See also SetStaticMeshAttachedTransform, RemoveStaticMeshAttached.

GetAllSkeletalMeshAttachedOptimal​

Gets all Skeletal Meshes attached to this entity

local ret = my_vehicle:GetAllSkeletalMeshAttached()
Returns
TypeDescription
table of stringthe key as the Attached ID, and the value as the Asset Path

GetAllStaticMeshAttachedOptimal​

Gets all Static Meshes attached to this entity

local ret = my_vehicle:GetAllStaticMeshAttached()
Returns
TypeDescription
table of stringthe key as the Attached ID, and the value as the Asset Path

RemoveAllSkeletalMeshesAttachedOptimal​

Removes all SkeletalMeshes attached

my_vehicle:RemoveAllSkeletalMeshesAttached()

RemoveAllStaticMeshesAttachedOptimal​

Removes all StaticMeshes attached

my_vehicle:RemoveAllStaticMeshesAttached()

RemoveSkeletalMeshAttachedOptimal​

Removes, if it exists, a SkeletalMesh from this Vehicle given its custom ID

my_vehicle:RemoveSkeletalMeshAttached(id)
Paramètres
NameTypeDescription
idstringUnique ID of the SkeletalMesh to remove

See also AddSkeletalMeshAttached.

RemoveStaticMeshAttachedOptimal​

Removes, if it exists, a StaticMesh from this Vehicle given its custom ID

my_vehicle:RemoveStaticMeshAttached(id)
Paramètres
NameTypeDescription
idstringUnique ID of the StaticMesh to remove

See also AddStaticMeshAttached.

SetStaticMeshAttachedTransformOptimal​

Sets a Static Mesh Attached location and rotation

my_vehicle:SetStaticMeshAttachedTransform(id, relative_location, relative_rotation)
Paramètres
NameTypeDescription
idstringUnique ID of the StaticMesh set with AddStaticMeshAttached
relative_locationVectorNew relative location
relative_rotationRotatorNew relative rotation

See also AddStaticMeshAttached.

Handlingfunctions​

IsEngineStartedOptimal​

Checks if the engine is started

local is_started = my_vehicle:IsEngineStarted()
Returns
TypeDescription
booleanWhether the engine is started

SetCameraArmLengthOptimal​

Sets how far the camera stays from this Vehicle while driving it

The length is in centimeters. This overrides the Player's own Camera Arm Length for as long as they are driving it. Set it to 0 to use the Player's value instead, which is the default

my_vehicle:SetCameraArmLength(arm_length)
Paramètres
NameTypeDescription
arm_lengthintegerThe distance in centimeters, or 0 to use the Player's own value

SetCameraOffsetOptimal​

Sets the Vehicle Camera Offset

my_vehicle:SetCameraOffset(offset)
Paramètres
NameTypeDescription
offsetVectorThe new Vehicle Camera Offset

Passengersfunctions​

GetDoorsModerate​

Gets all configured Doors

local ret = my_vehicle:GetDoors()
Returns
TypeDescription
tableAll configured Doors
Table keys
NameTypeDescription
seat_indexintegerNo description provided
offset_locationVectorNo description provided
seat_locationVectorNo description provided
seat_rotationRotatorNo description provided
leave_lateral_offsetintegerNo description provided
sphere_radiusintegerNo description provided

GetPassengerOptimal​

Gets a passenger from a seat

local passenger = my_vehicle:GetPassenger(seat)
Paramètres
NameTypeDescription
seatintegerIndex of the seat, 0 is the driver
Returns
TypeDescription
Characteror nil if no passenger in seat

GetPassengersModerate​

Gets all passengers

local passengers = my_vehicle:GetPassengers()
Returns
TypeDescription
table of CharacterAll passengers

SetDoorOptimal​

Adds a Door to the Vehicle

Adds a Door at offset_location from root which will pose the Character at seat_location with seat_rotation rotation

my_vehicle:SetDoor(seat_index, offset_location, seat_location, seat_rotation, trigger_radius, leave_lateral_offset)
Paramètres
NameTypeDescription
seat_indexintegerIndex of the seat, 0 is the driver
offset_locationVectorLocation of the door trigger relative to the vehicle
seat_locationVectorLocation of the seat relative to the vehicle
seat_rotationRotatorRotation of the seat relative to the vehicle
trigger_radiusintegerRadius of the trigger used to enter through this door
leave_lateral_offsetintegerIt's where the Character will be ejected when leaving it (e.g. -150 for left door or 150 for right door)

Physicsfunctions​

SetBuoyancyPontoonsModerate​

Sets the Buoyancy Pontoons used by the Water simulation

Sets the spherical Pontoons used to float this entity on Water, overriding the ones automatically calculated from the Mesh bounds and mass.

Pass no value (or an empty table) to go back to the automatically calculated ones.

Pontoons only have an effect on Maps with Water Buoyancy enabled

my_vehicle:SetBuoyancyPontoons(pontoons?)
Paramètres
NameTypeDescription
pontoons?tableArray with the Pontoons, or nil to restore the automatically calculated ones Par défaut nil
Table keys
NameTypeDescription
OffsetVectorLocation relative to the entity
RadiusfloatRadius of the Pontoon sphere, must be greater than 0

SetBuoyancySettingsModerate​

Sets how this entity behaves on Water

Any value passed as nil restores that setting's default.

The automatically calculated Pontoons are sized for the default buoyancy_coefficient, so a higher one makes the entity float higher

my_vehicle:SetBuoyancySettings(enabled?, buoyancy_coefficient?, buoyancy_damp?, max_buoyant_force?)
Paramètres
NameTypeDescription
enabled?booleanWhether Buoyancy forces are applied at all Par défaut true
buoyancy_coefficient?floatHow much it floats, the higher the more Par défaut 0.1
buoyancy_damp?floatFirst order damping on the vertical velocity, reduces bobbing. When nil (or negative) it is calculated from the mass and Pontoons Par défaut nil
max_buoyant_force?floatClamp on the upwards force, stops light objects being launched out of the water Par défaut 1000000000

SetExplosionSettingsOptimal​

Configures the Explosion Settings when health reaches zero

my_vehicle:SetExplosionSettings(engine_relative_location, materials_index_burnt_override, materials_index_burnt_invisible)
Paramètres
NameTypeDescription
engine_relative_locationVectorRelative location of the Engine. Used to apply particles and effects
materials_index_burnt_overridetableList of material indexes to override to burnt when exploded. Leave it empty for all indexes
materials_index_burnt_invisibletableList of material indexes to override to invisible when exploded. Leave it empty for all indexes
Examples (1)
Vehicle Explosion Settings
my_vehicle:SetExplosionSettings(Vector(-50, 0, 0), { 1, 2, 4 }, { 3 })

🚀 Events​

CharacterAttemptEnterTriggered when a Character attempts to enter the Vehicle
CharacterAttemptLeaveTriggered when a Character attempts to leave the Vehicle
CharacterEnterTriggered when a Character fully enters the Vehicle
CharacterLeaveTriggered when a Character fully leaves the Vehicle
EngineStartTriggered when the engine starts
EngineStopTriggered when the engine stops
HitTriggered when Vehicle hits something

CharacterAttemptEnter​

Triggered when a Character attempts to enter the Vehicle

<AnyVehicleClass>.Subscribe("CharacterAttemptEnter", function(self, character, seat)
-- CharacterAttemptEnter was called
return true
end)
Arguments
NameTypeDescription
selfBase VehicleThe Vehicle that triggered the event
characterCharacterThe Character
seatintegerThe seat index
Returns
TypeDescription
booleanReturn false to prevent it

CharacterAttemptLeave​

Triggered when a Character attempts to leave the Vehicle

<AnyVehicleClass>.Subscribe("CharacterAttemptLeave", function(self, character)
-- CharacterAttemptLeave was called
return true
end)
Arguments
NameTypeDescription
selfBase VehicleThe Vehicle that triggered the event
characterCharacterThe Character
Returns
TypeDescription
booleanReturn false to prevent it

CharacterEnter​

Triggered when a Character fully enters the Vehicle

<AnyVehicleClass>.Subscribe("CharacterEnter", function(self, character, seat_index)
-- CharacterEnter was called
end)
Arguments
NameTypeDescription
selfBase VehicleThe Vehicle that triggered the event
characterCharacterThe Character
seat_indexintegerThe seat entered, 0 is the driver

CharacterLeave​

Triggered when a Character fully leaves the Vehicle

<AnyVehicleClass>.Subscribe("CharacterLeave", function(self, character, seat_index)
-- CharacterLeave was called
end)
Arguments
NameTypeDescription
selfBase VehicleThe Vehicle that triggered the event
characterCharacterThe Character
seat_indexintegerThe seat left, 0 is the driver

EngineStart​

Triggered when the engine starts

<AnyVehicleClass>.Subscribe("EngineStart", function(self)
-- EngineStart was called
end)
Arguments
NameTypeDescription
selfBase VehicleThe Vehicle that triggered the event

EngineStop​

Triggered when the engine stops

<AnyVehicleClass>.Subscribe("EngineStop", function(self)
-- EngineStop was called
end)
Arguments
NameTypeDescription
selfBase VehicleThe Vehicle that triggered the event

Hit​

Triggered when Vehicle hits something

<AnyVehicleClass>.Subscribe("Hit", function(self, impact_force, normal_impulse, impact_location, velocity, other_actor)
-- Hit was called
end)
Arguments
NameTypeDescription
selfBase VehicleThe Vehicle that triggered the event
impact_forcefloatThe intensity of the Hit normalized by the Vehicle's weight
normal_impulseVectorLa direction de l'impulsion qu'elle donne
impact_locationVectorLa position dans le monde de l'impact
velocityVectorThe Vehicle velocity at the moment it hits
other_actorBase Actor or nilThe other actor that hit this Vehicle