Rotate locally based on Entity's Angles?


I am currently working on a tripmine deploying SWEP and have run into a hiccup.

On spawning the tripmine, the angles are set to the Hitnormal of the Trace Result from the player’s eyes to always ensure it faces away from the surface they were deploying on.

However the tripmine by default will always face 90 degrees to the left instead of straight at the player.

Any hard corrections made will cause the tripmine to face correctly when placed on walls but then face incorrectly when placed on the ground / ceiling and vice versa.

What I am wondering is if there is a way to rotate an entity based on IT’S angles, rather than the WORLD’s angles. Because I need the entity to be rotated 90 degrees to IT"S right.

Apologies if this does not seem to make any sense, I’m a touch tired (and frustrated) from going at this all day and to no avail.

Thank you for your time.

Is this what you are talking about?



So let’s call your tripmine the ‘Entity’ in what I’m about to describe. You could do

local mineAngles = Entity:GetAngles()
local newMineAngles = mineAngles:RotateAroundAxis( mineAngles:Right(), 90 )
Entity:SetAngles( newMineAngles )

Something like that

You are a lifesaver,

I was actually close, but also so far. Resulting to using LocalToWorld like a fool.

Cheers mate.

1 Like