So this is a unique issue with all the entities that get spawned into the map with the class name prop_physics* i make it so i can detect collisions on them with normal props. and with specific props they collide with set collision groups dynamicly. But it crashes my game and i am not sure how to overcome or solve this annoying problem.
[CODE]
local function EntityCreated( entity )
if string.match(entity:GetClass(), "prop_physics*") then
entity:SetCustomCollisionCheck(true)
end
end
hook.Add("OnEntityCreated", "entity.Created", EntityCreated)
hook.Add("ShouldCollide", "Prop.Collision", function(player, object)
if player:IsValid() and player:IsPlayer() then
else
if player:IsValid() and object:IsValid() then
if string.match(player:GetClass(), "prop_physics*") and player:IsPlayerHolding() != true and string.match(object:GetClass(), "prop_spotlamp*") then
object:SetCollisionGroup(COLLISION_GROUP_WORLD)
player:SetCollisionGroup(COLLISION_GROUP_WORLD)
timer.Simple(1, function()
--Set the prop back to its default collision state
player:SetCollisionGroup(COLLISION_GROUP_NONE)
end)
end
end
end
end)[/CODE]
I'm pretty sure it's a really bad idea to change collision groups in that hook. And i'm also sure that is not how you should be using that hook. Read: [url]http://wiki.garrysmod.com/page/GM/ShouldCollide[/url]
I solved my problem now topic can be closed or marked as solved.
You can do that by yourself...
Sorry, you need to Log In to post a reply to this thread.