Voltaism Dev Tips: Difference between revisions
From Onset Developer Wiki
add client tip |
add client tip |
||
Line 37: | Line 37: | ||
v:SetCollisionResponseToChannel(ECollisionChannel.ECC_GameTraceChannel1, ECollisionResponse.ECR_Ignore) -- Disable skeletal mesh component collision with bullets | v:SetCollisionResponseToChannel(ECollisionChannel.ECC_GameTraceChannel1, ECollisionResponse.ECR_Ignore) -- Disable skeletal mesh component collision with bullets | ||
end | end | ||
end | |||
</syntaxhighlight> | |||
==== Change vehicle velocity ==== | |||
<syntaxhighlight lang="Lua"> | |||
local veh = GetPlayerVehicle(GetPlayerId()) | |||
if (veh ~= 0 and IsValidVehicle(veh) and GetVehicleDriver(veh) == GetPlayerId()) then -- The player has to be the driver or the vehicle won't be synced | |||
local vehsk = GetVehicleSkeletalMeshComponent(veh) | |||
vehsk:SetPhysicsAngularVelocityInDegrees(FVector(vax, vay, vaz), bAddToCurrent) | |||
vehsk:SetPhysicsLinearVelocity(FVector(vx, vy, vz), bAddToCurrent) | |||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 20:57, 6 July 2021
WIP
Serverside Tips
Restart self using an exported function
Package 1:
function RestartPackage(package_name)
Delay(1, function()
StopPackage(package_name)
end)
Delay(1000, function()
StartPackage(package_name)
end)
return true
end
AddFunctionExport("RestartPackage", RestartPackage)
Package 2:
local package1 = ImportPackage("package1")
package1.RestartPackage(GetPackageName())
Clientside Tips
Disable a remote player/npc collisions properly
local npc_actor = GetNPCActor(npc)
local Capsule = npc_actor:GetComponentsByClass(UCapsuleComponent.Class())[1] -- Get capsule component of the npc actor
Capsule:SetCollisionResponseToChannel(ECollisionChannel.ECC_Pawn, ECollisionResponse.ECR_Ignore) -- Disable Capsule collision with players
Capsule:SetCollisionResponseToChannel(ECollisionChannel.ECC_Camera, ECollisionResponse.ECR_Ignore) -- Disable capsule collision with camera
Capsule:SetCollisionResponseToChannel(ECollisionChannel.ECC_GameTraceChannel1, ECollisionResponse.ECR_Ignore) -- Disable capsule collision with bullets
for i, v in ipairs(npc_actor:GetComponents()) do
if v:GetClassName() == "USkeletalMeshComponent" then
v:SetCollisionResponseToChannel(ECollisionChannel.ECC_GameTraceChannel1, ECollisionResponse.ECR_Ignore) -- Disable skeletal mesh component collision with bullets
end
end
Change vehicle velocity
local veh = GetPlayerVehicle(GetPlayerId())
if (veh ~= 0 and IsValidVehicle(veh) and GetVehicleDriver(veh) == GetPlayerId()) then -- The player has to be the driver or the vehicle won't be synced
local vehsk = GetVehicleSkeletalMeshComponent(veh)
vehsk:SetPhysicsAngularVelocityInDegrees(FVector(vax, vay, vaz), bAddToCurrent)
vehsk:SetPhysicsLinearVelocity(FVector(vx, vy, vz), bAddToCurrent)
end
Global/Other Tips
Call/Edit a function/variable with a string
_ENV["function_" .. "test"] = function(nb)
print("Hi", nb)
end
function_test(0)
_ENV["function_test"](1)
_ENV["vartest"] = 1
print(vartest)
print(_ENV["vartest"])