Silly question about locking rotations.

Im trying to lock the rotation of my entity, but it needs to continue to have other physics behave fine. For example I want it to slide across the floor (using a physics material) but I want to completely lock its rotation without any glitching/bugging but it still needs to slide fine. Thanks.

try putting ent:SetAngles(Angle(whatever)) in ENT:Think or something similar

I’v tried most of the obvious stuff, this just causes it to bug a little bit. For example if the entity is still, this results in it constantly vibrating which in turn results in it moving when it should not be.

constraint.Keepupright may work

Keepupright is not like solid angles though, its kinda of like an elastic kinda effect where the prop can still rotate but it bounces back, I need to lock it 0,0,0 and no matter what happens to then entity the angles stay at 0,0,0

good luck

Thanks :confused:

What exactly are you trying to achieve(aside from the obvious where you don’t want an entity to rotate)? If you only need it to APPEAR to be upright at all times, you can use its draw function and draw a Clientside model with the angles needed at the Entities position, so it appears to not be rotating at all (when it actually is).

If you need the physics to line up perfectly with the rendered model though, you may need to look into other options below.

Look into Physics Shadows:

If you can’t get that to work perhaps try using StartMotionController and PhysObj:SetAngles in the simulate physics function on the entity.

You can also look into this and set the angular dampening to pretty high:

Tried all of these to no avail, the only thing that really worked was setting the physenv settings to stop all angular velocity, this works perfectly how ever this breaks any moving objects in the map which is a bit of an issue.

This is probably retarded but fuck it lmao

local ent = FindMetaTable 'Entity'
ent.oldsetangles = ent.oldsetangles or ent.SetAngles

function ent:SetAngles( ang )

	if self:GetClass() == 'yourentclassnigga' then
		self:oldsetangles( Angle( 0, 0, 0 ) )

	self:oldsetangles( ang )


and just put it in ENT:Think() hook or some shit idk


or do i not get what ur tryna do?

Workshop Addon “Physgun build mode” achieves picking up the entity, the entity retains its angles the same as it had when it was picked up - Just debug his code that might help you

I think Think runs slower than physic resolving (Due runs on engine) and all that stuff related to prediction

hook.Add("Tick", "test", function()
    for k,v in next, ents.GetAll() do
        if v:GetClass() == "gayent" then
            v:SetAngles(v.RestrictedAngle and v.RestrictedAngle or Angle(0, 0, 0))

might work

None of these work. Setting the angle in a think/tick/physicsupdate hook just causes unwanted behavior such as the entity constantly moving left. The entity needs to keep all of its physics as normaly except lock rotation, kinda like what disable rotation on a rigidbody does in unity.

Thank for the help though guys.

Again, what exactly are you trying to do with this? If you can explain your end goal aside from keeping the ent upright, that may help us come up with a solution that may suit your needs.

I have a ball, and its pretty small and source really isn’t good at accurately simulator small physics, so instead of actually letting the ball roll, instead it slides around and I manual calculate how it should bounce of things etc. This works really well and it behaves like a ball but if its moving slowly and it rotates then it causes unwanted side effects like the ball changing direction when it should not etc. This is why I need to lock the rotation completely.

could you try ? I used this for some grenades I wrote and it was very consistent, I was able to land the same grenade rebound every throw

:open_mouth: I Did not know this existed, I will test it right away!


It worked, your my hero <3