GetVehicleSkeletalMeshComponent

From Onset Developer Wiki
Revision as of 15:33, 11 November 2020 by BlueMountains (talk | contribs) (Created page with "{{Info|Function|Client|1.0}} {{FuncDescription|Gets the skeletal mesh component of a vehicle.}} {{FuncSyntax|GetVehicleSkeletalMeshComponent(vehicle)}} {{FuncParameters}} {...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
GetVehicleSkeletalMeshComponent

Type: Function
Context: Client
Introduced: v1.0

Description

Gets the skeletal mesh component of a vehicle.

Syntax

GetVehicleSkeletalMeshComponent(vehicle)

Parameters

  • vehicle
    The vehicle identifier.

Return Value

  • Returns USkeletalMeshComponent and then can be used by UnrealLua.

Example

local function OnKeyPress(key)
	local vehicle = GetPlayerVehicle(GetPlayerId())
	if vehicle ~= 0 then
		local VehicleSkeletalMeshComponent = GetVehicleSkeletalMeshComponent(vehicle)
		if GetVehicleDriver(vehicle) == GetPlayerId() then
			if key == 'H' then
				VehicleSkeletalMeshComponent:SetPhysicsLinearVelocity(FVector(0.0, 0.0, 800.0), true)
			end
			
			if (key == '2' or key == 'é') then
				VehicleSkeletalMeshComponent:SetPhysicsLinearVelocity(FVector(0.0, 0.0, 0.0), false)
				VehicleSkeletalMeshComponent:SetPhysicsAngularVelocityInDegrees(FVector(0.0, 0.0, 0.0), false)
			end
			
			if key == "Left Mouse Button" then
				local x, y, z = GetVehicleVelocity(vehicle)
			    local size = x * x + y * y + z * z
				if (size < 25000000) then
					local mult = 0.3
					VehicleSkeletalMeshComponent:SetPhysicsLinearVelocity(FVector(x * mult, y * mult, z * mult), true)
				end
			end
	    end
	end
end
AddEvent("OnKeyPress", OnKeyPress)

See also

__EDIT_ME__