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()
	self:SetModel("models/Zombie/Classic.mdl");
	self:SetHealth(150);

	local headcrab = ents.Create("npc_headcrab")
	local attachment = self:GetAttachment(self:LookupAttachment("headcrab"));
	headcrab:SetPos(attachment.Pos);
	headcrab:Spawn();
	headcrab:SetParent(self, 1);
	headcrab:SetSolid(SOLID_NONE);
end


Any ideas would be appreciated.

Thanks

Zombie model has a bodygroup for this.

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

-snip-

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?

http://forum.facepunch.com/showthread.php?t=1167676&p=34971687&viewfull=1#post34971687

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: