Bind rotation to a single axis

Is there anyway to bind the rotation of an entity to a single axis?
In my morph ball SWEP when its rolling around its just going anywhich way, but the texture on the ball makes it look REALLY weird, and I want to have kind of like a tire effect on it, making it only roll forward so the texture isn’t making it look weird.
(Sorry for the conveluded description)

This would be useful to make 2D-like gamemodes too

I asked for help in the Help thread for this as well, but that conversation got pushed back and I don’t want to bring it back to the front when other people need help there, so I’ll just hope I get some posts here.

Ive tried using a ShadowController to adjust the angles, and that KINDA works, but the angle of the ball is offset and whenever I try to undo the offset the ball just continually spins.

Ive also tried setting the balls angles depending on what keys are pressed, and rolling it on its forward that way, but that didnt work either.

I knew that the shadow control wouldn’t be all that great, so I started messing around with other ideas. Youre best bet is the simulated physics.

[lua]
AddCSLuaFile( “cl_init.lua” )
AddCSLuaFile( “shared.lua” )
include( ‘shared.lua’ )

// This is the spawn function. It’s called when a client calls the entity to be spawned.
// If you want to make your SENT spawnable you need one of these functions to properly create the entity
//
// ply is the name of the player that is spawning it
// tr is the trace from the player’s eyes
//
function ENT:SpawnFunction( ply, tr )

if ( !tr.Hit ) then return end

local SpawnPos = tr.HitPos + tr.HitNormal * 16

local ent = ents.Create( self.ClassName )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()

return ent

end

/---------------------------------------------------------
Name: Initialize
---------------------------------------------------------
/
function ENT:Initialize()

// Use the helibomb model just for the shadow (because it's about the same size)
self:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" )
--[[self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self:PhysWake()]]

// Don't use the model's physics - create a sphere instead
self.Entity:PhysicsInitSphere( 16, "metal" )

// Wake the physics object up. It's time to have fun!
local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
	phys:Wake()
end

// Set collision bounds exactly
self.Entity:SetCollisionBounds( Vector( -16, -16, -16 ), Vector( 16, 16, 16 ) )

self.ShadowParams = {}
self.CurrentAngles = Angle( 0, 0, 0 )
self:StartMotionController()

end

/---------------------------------------------------------
Name: PhysicsCollide
---------------------------------------------------------
/
function ENT:PhysicsCollide( data, physobj )
end

/---------------------------------------------------------
Name: OnTakeDamage
---------------------------------------------------------
/
function ENT:OnTakeDamage( dmginfo )

// React physically when shot/getting blown
self:TakePhysicsDamage( dmginfo )

end

local forceangular = vector_origin

function ENT:PhysicsSimulate( phys, deltatime )

phys:Wake()

if !IsValid( self.Controller ) then
	return SIM_NOTHING
end

self.CurrentAngles = self:GetAngles()	

--self.CurrentAngles:RotateAroundAxis( self.CurrentAngles:Forward(), 90 )

local rollforce = ( self:GetForward() * ( self.CurrentAngles.p ) ) * -32 + ( self:GetRight() * ( self.CurrentAngles.r ) ) * -32
_, forceangular = phys:CalculateForceOffset( rollforce, self:GetPos() + ( self:GetUp() * 90 ) )

--forceangular:RotateAroundAxis( forceangular:Forward(), 90 )

return forceangular, vector_origin, SIM_GLOBAL_ACCELERATION

end

/---------------------------------------------------------
Name: Use
---------------------------------------------------------
/
function ENT:Use( activator, caller )

self.Controller = activator

end[/lua]

This was just something I was messing with. I managed to recreate the keepupright tool effect using SIM_GLOBAL_ACCELERATION. The thing is I couldn’t figure out how change the effect for use with your ball. I don’t know, but maybe this will get you pointed in the right direction.

This definitly makes the movement smoother, and when i stop moving the ball rolls around in a circle which is AWESOME, but doesnt solve the issue im trying to fix, which is keeping it upright. It still seemed to roll anywhich way