Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Cannot destroy physics in a physics callback" LUA error appearing after recent Gmod changes #5824

Closed
DopeyPepsee opened this issue Apr 4, 2024 · 2 comments

Comments

@DopeyPepsee
Copy link

Hello! Apologies for any inconvenience, I am posting this rather for an informative reply rather than a fix per say.
I went back to playing around with an old add-on of mine when I noticed this error that started popping up anytime one of the NextBots would be killed by being blown up, it would happen.

[iv04] Cannot destroy physics in a physics callback!
  1. Giv - addons/iv04/lua/entities/npc_iv04_weaponuserbase/shared.lua:67
   2. unknown - addons/halo ce nextbots/lua/entities/npc_iv04_hce_marine/shared.lua:1711 (x3)

Here is the function mentioned

function ENT:Give(wep)
	local wep = ents.Create(wep)
	local pos = self:GetAttachment(self:LookupAttachment("anim_attachment_RH")).Pos
	wep:SetOwner(self)
	wep:SetPos(pos)
	wep:Spawn()
	wep:PhysicsInit(SOLID_NONE)
	wep:SetSolid(SOLID_NONE)
	wep:SetParent(self)
	wep:Fire("setparentattachment", "anim_attachment_RH")
	wep:AddEffects(EF_BONEMERGE)
	self.Weapon = wep
end

This is line 67:
wep:PhysicsInit(SOLID_NONE)

Thank you for your time, please let me know what I'm missing or doing wrong in order to fix this.
Best regards!

@robotboy655
Copy link
Contributor

This is not really a place to seek modding help. You can do so on the official Discord server linked in the README.

That being said, the error you are experiencing should be self explanatory - You cannot destroy physics objects (done via PhysicsInit if the entity already has a physics object) during a physics callback because that would lead to a crash.

You have to avoid doing so by delaying the physics callbacks in some way.

@robotboy655 robotboy655 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 4, 2024
@Kefta
Copy link
Contributor

Kefta commented Apr 4, 2024

That "some way" should be Facepunch/garrysmod-requests#894 ideally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants