Enabling Attached Object Collision: Difference between revisions
From Onset Developer Wiki
m BlueMountains moved page AttachedObjectsCollision to Enabling Attached Object Collision without leaving a redirect |
No edit summary |
||
Line 1: | Line 1: | ||
SetObjectAttached disables the collision of | [[SetObjectAttached]] disables the collision of objects. | ||
Here is how to enable collision. | Here is how to enable collision for attached objects again. Be careful when collisions overlap vehicles. | ||
server.lua: | server.lua: |
Latest revision as of 16:36, 8 October 2020
SetObjectAttached disables the collision of objects. Here is how to enable collision for attached objects again. Be careful when collisions overlap vehicles.
server.lua:
--- Set this property value to your attached object:
SetObjectPropertyValue(o, "_enableCollision", true)
client.lua:
AddEvent("OnObjectStreamIn", function(object)
local _enableCollision = GetObjectPropertyValue(object, "_enableCollision")
if _enableCollision == true then
-- We need to delay enabling the collision. Attached objects have their collision set in the attach RPC that comes after the stream event.
Delay(200, function(object)
if IsValidObject(object) then
GetObjectActor(object):SetActorEnableCollision(true)
local SMC = GetObjectStaticMeshComponent(object)
SMC:SetMobility(EComponentMobility.Movable)
SMC:SetCollisionEnabled(ECollisionEnabled.QueryAndPhysics)
print("Enabled collision")
end
end, object)
end
end)