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.
[QUOTE=0V3RR1D3;51624794]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.[/QUOTE]
try putting ent:SetAngles(Angle(whatever)) in ENT:Think or something similar
[QUOTE=kaliii;51625223]try putting ent:SetAngles(Angle(whatever)) in ENT:Think or something similar[/QUOTE]
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.
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/constraint/Keepupright]constraint.Keepupright[/url] may work
[QUOTE=MPan1;51625453][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/constraint/Keepupright]constraint.Keepupright[/url] may work[/QUOTE]
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
[QUOTE=0V3RR1D3;51627746]I need to lock it 0,0,0 and no matter what happens to then entity the angles stay at 0,0,0[/QUOTE]
good luck
[QUOTE=MPan1;51628333]good luck[/QUOTE]
Thanks :/
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:
[url]https://wiki.garrysmod.com/page/Entity/PhysicsInitShadow[/url]
[url]https://wiki.garrysmod.com/page/PhysObj/UpdateShadow[/url]
[url]https://wiki.garrysmod.com/page/PhysObj/ComputeShadowControl[/url]
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:
[url]https://wiki.garrysmod.com/page/PhysObj/SetDamping[/url]
[QUOTE=Brassx;51628736]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:
[url]https://wiki.garrysmod.com/page/Entity/PhysicsInitShadow[/url]
[url]https://wiki.garrysmod.com/page/PhysObj/UpdateShadow[/url]
[url]https://wiki.garrysmod.com/page/PhysObj/ComputeShadowControl[/url]
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:
[url]https://wiki.garrysmod.com/page/PhysObj/SetDamping[/url][/QUOTE]
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
[code]
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 ) )
return
end
self:oldsetangles( ang )
end
[/code]
and just put it in ENT:Think() hook or some shit idk
Edit:
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
[code]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))
end
end
end)[/code]
might work
idk
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.
[QUOTE=Brassx;51631296]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.[/QUOTE]
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 [url]http://wiki.garrysmod.com/page/Entity/PhysicsInitSphere[/url] ? I used this for some grenades I wrote and it was very consistent, I was able to land the same grenade rebound every throw
[QUOTE=Arizard;51633427]could you try [url]http://wiki.garrysmod.com/page/Entity/PhysicsInitSphere[/url] ? I used this for some grenades I wrote and it was very consistent, I was able to land the same grenade rebound every throw[/QUOTE]
:O I Did not know this existed, I will test it right away!
Edit:
It worked, your my hero <3
Sorry, you need to Log In to post a reply to this thread.