Pos only Parent

Hey. Short and sweet.

Is there any way to somehow parent and entity to another without it affecting angles? I need the entity to follow it’s parents’ position, but not angles.

I don’t think so. Parenting is a Source feature and VALVe designed it as a way to copy both.

Probably not a great way of doing it, but you could update the entities position to the parents position (+offset) in a think hook.

Use ENT:PhysicsUpdate if that’s what you’re going to do. Anyways, a better solution might be a shadow controller, depending on what you’re trying to do.

What about a rope from the centre of one prop to the other with rigid on? That way they’d stay the same distance apart but they can turn all they want. I’m pretty sure that would work exactly like a ‘position only parent’.

I’ve tried something very similar to this in a draw hook (It’s clientside.)

It works for the most part, but it’s far too jerky.

Make sure you set the render position before DrawModel().

I am, it still has some slight moments when it jerks or lags slightly.

—Edit

Okay, it lags behind a bit while the prop tries to apply angles. I’ve meneged to get around it by using both ENT:Draw() and ENT:Think().


function ENT:Draw()
	if self.Entity:GetOwner() == LocalPlayer() then
		local rot = LocalPlayer():EyeAngles()
		self.Entity:SetAngles(Angle(0,rot.y,0))
	end
	self.Entity:DrawModel()
end

function ENT:Think()
	if self.Entity:GetOwner() == LocalPlayer() then
		self.Entity:SetPos(LocalPlayer():GetPos())
	end
end

This works, looks just like a parent, but I can control the angles. I’m not really happy with this method though, feels kind of hacky. If anyone has any better ideas, please do let me know.

Did you try my idea yet?

Do it every tick!


function ENT:Draw()
	if self:GetOwner() == LocalPlayer() then
		local rot = LocalPlayer():EyeAngles()
		self:SetRenderOrigin(LocalPlayer():GetPos())
		self:SetRenderAngles(Angle(0,rot.y,0)
	end
	self:DrawModel()
end

:eng101:

=O

Yay, you rawk.

I think someone needs to explain the difference between “tick” and “think”.
Tick is networking-related. Whenever a tick-frame is reached serverside, the server sends out data to the client. Whenever a tick-frame is reached clientside, the client processes the data received from the server for that tick. Ticks occurs less frequently than Think, which occurs once every frame. If it was something you’d want to correct at the start of every frame, you’d do it on Think. If it was something networking related you’d want to do, you’d do it on Tick.