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

Entity:SetSurroundingBoundsType(BOUNDS_HITBOXES) makes PCF effects and other things use bad bone positions #6028

Open
NO-LOAFING opened this issue Oct 12, 2024 · 1 comment

Comments

@NO-LOAFING
Copy link

When Entity:SetSurroundingBoundsType(BOUNDS_HITBOXES) is run on an entity, attached PCF particle effects using operator Movement Lock to Bone will be disconnected from the position of the model, and will instead appear slightly ahead of its current position, both from the movement of the entity itself, and from the bone movements of its animation.

If the entity is also playing an animation layer with Entity:AddLayeredSequence, this bug happens all the time, but if it isn't playing an animation layer, the bug only seems to occur when the entity's angles are changing.

Here's the code for the test entity I've been using to narrow down the bug, I've confirmed it on both the main branch and dev branch.

AddCSLuaFile()

ENT.Base = "base_gmodentity"
ENT.AutomaticFrameAdvance = true
ENT.Spawnable = true


function ENT:Initialize()

	self:SetModel("models/player/scout.mdl")
	if SERVER then
		self:ResetSequence(self:LookupSequence("airwalk_loser"))
		self:SetPlaybackRate(1)
		self:AddLayeredSequence(self:LookupSequence("gesture_primary_go"), 1) //without this line, the bug only occurs when the ent rotates
		//self:Ignite(math.huge) //alternative to CreateParticleEffect below
	elseif CLIENT then
		self:CreateParticleEffect("burningplayer_blue", {
			{entity = self, attachtype = PATTACH_ABSORIGIN_FOLLOW}
		})
	end

	self:SetCollisionBounds(Vector(-3,-3,-3),Vector(3,3,3)) //collision bounds that don't match hitbox bounds, to necessitate BOUNDS_HITBOXES
	self:SetSolid(SOLID_BBOX)
	self:SetMoveType(MOVETYPE_NONE)
	self:SetSurroundingBoundsType(BOUNDS_HITBOXES)

end


function ENT:Think()

	self:NextThink(CurTime())
	return true

end
2024-10-12.15-47-31.mp4

There's definitely something more going on internally beyond the PCF effects, because it also A: affects the bone positions shown by the Easy Entity Inspector addon, and B: doesn't need the animation layer or angle change to cause the bug if the Easy Entity Inspector is hovering over the model, but that's all beyond what I've been able to look into so far.

2024-10-12.16-22-48.surroundingbounds.bug.inspector2.mp4
@Goldermor
Copy link

Huh it's a very freaky thing. And maybe it has something to do with prediction? If player holds the entity while in noclip, the glitch disappears, step on the ground and it happens again.
The shift of all particles occurs only if MOVETYPE_NONE, but the position relative to the bones is still incorrect in all other move types.

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

2 participants