Attaching a headcrab to a NextBot

Is it possible?

I’m currently trying to re-create the original half life zombies using nextbots, and for the zombie I would like a headcrab to be attached to him.

I tried doing this, but the headcrab would just slide off/be attached weirdly/still be awake:

function ENT:Initialize()

	local headcrab = ents.Create("npc_headcrab")
	local attachment = self:GetAttachment(self:LookupAttachment("headcrab"));
	headcrab:SetParent(self, 1);

Any ideas would be appreciated.


Zombie model has a bodygroup for this.

What you are doing is wrong, its not how its done.


nevermind, thank you!

[editline]23rd September 2016[/editline]

Sorry, I have one more question. Is there a way to see if a nextbot got headshotted?

But those hooks are for when a player gets hit, not a nextbot, and the nexbot OnInjured function doesn’t give you the hitgroup they were hit in anyway.

Look through this file, they found a way to get the position out of hitboxes, complicated for beginners, but should work:

And they made a custom OnInjured function, where they use the top table of the hitboxes, found at the bottom(or simply use the link)

Nothing is impossible :wink: