Entity OBB Rotation Server Side?

In my map, I have entities with varying size depending on their spawning location and environment, they’re all static but may have different angles. The OBB is set when they spawn via Initialize, everything is working perfectly except for the fact that the OBB isn’t rotating (server-side) with the entity but does it flawlessly client-side…

Here’s an ingame exemple:

In blue, those are actual beams drawn with the OBB’s coordonates (client-side).
In red, those are the actual server side Bounding Boxes… (drawn in paint)

As you can see, even if the “beam wall” is angled, the actual bounding box is’nt…

Here’s my code in ENT:Initialize():
self.Entity.cMin = Vector( -midDist, 0, 0 ) – Don’t mind those, they are valid Vectors
self.Entity.cMax = Vector( midDist, 0, gamemode.AreaPortalHeight ) – Same here, valid vectors I verified them (often)

self.Entity:SetCollisionBounds( self.Entity.cMin, self.Entity.cMax )
self.Entity:SetSolid( SOLID_BBOX )
self.Entity:PhysWake() self.Entity:SetTrigger( true )
self.Entity:SetNotSolid( true )

I’m no lua king but you might need to use a networked variable to communicate between server and client.

I think but don’t take my word as I only just started learning lua 1 month ago.

To my knowledge all OBB functions return local coordinates so unless you by OBB mean something else, there is a problem with your debug rendering code.

I use LocalToWorld() to draw the client OBBs.

Also, I tried a small debug function in the ENT:Use() which would rotate it when I pressed E on it but still, the entity rotate but not the bounding box…

Well, are you using LocalToWorld in that function too? Give more details and/or code.

Here’s my clientside rendering code:

if gamemode.EditMode == true then

    local ang = self:GetAngles()
    self:SetAngles( ang + Angle( 0, 90, 0 )) -- Don't mind this part, it's because the OBB render's with a 90 degree off.
    obbMax = self:OBBMaxs()
    obbMin = self:OBBMins()
    vMax = self:LocalToWorld( obbMax )
    vMin = self:LocalToWorld( obbMin )
    v3 = Vector( vMin.x, vMin.y, vMax.z )
    v4 = Vector( vMax.x, vMax.y, vMin.z )

    render.SetMaterial( Laser )
    render.DrawBeam( vMax, v3, 5, 0, 0, Color( 255, 255, blue, 255 ) ) 
    render.DrawBeam( v3, vMin, 5, 0, 0, Color( 255, 255, blue, 255 ) ) 
    render.DrawBeam( vMin, v4, 5, 0, 0, Color( 255, 255, blue, 255 ) ) 
    render.DrawBeam( v4, vMax, 5, 0, 0, Color( 255, 255, blue, 255 ) ) 

    self:SetAngles( ang )


And the server-side part where you say it does not rotate?

This is the whole function creating the portal and as you will see, I set the angles of the entity depending on the player’s angle. Although, the OBB never change direction (How do I know? Well, I have an ENT:Touch function that prints “LOL” to the console and I can accuratly tell when my player stands in the OBB by watching the console as I move. Oddly enough, it always print when I’m on the side of my entity no matter where it points at.

Think of a fence you place where you stand, the face is 2 units wide and 100 units long, oddly enough, no matter how you place the face it’ll always block players on the X axis.

Whole CreateAreaPortal function
function CreateAreaPortal( ply, cmd, args )
if gamemode.EditMode == false then NotEdit( ply ) else

	-- Where are we aiming at?
	local trace = util.QuickTrace( ply:GetShootPos(), ply:GetAimVector() * 5000, { ply } )
	if trace.HitWorld and not trace.HitSky then
		local yaw = math.Round( ply:EyeAngles().y )
		local newPos = SnapPos32( trace.HitPos )
		newPos.z = math.ceil( newPos.z )
		yaw = RoundTo( yaw, 45 ) -- Custom function to round to a certain number (45 here).
		local ap = ents.Create( "area_portal" )
			ap:SetPos( newPos )
			ap:SetAngles( Angle( 0, yaw, 0 ) )
			-- Trace lines to find the lenght of the Area portal (Right + Left)
			local apRight = ap:GetRight()
			local trRight = util.QuickTrace( ap:GetPos(), apRight * 500, { ply, ap } )
			local trLeft = util.QuickTrace( ap:GetPos(), apRight * -500, { ply, ap } )
			local trMid
			local dist = 0
			-- Check if they hit then do some calculations
			if trRight.HitWorld and trLeft.HitWorld and not trRight.HitSky and not trLeft.HitSky then
				-- Get teh distance, divide it by 2 to get the middle point
				dist = trRight.HitPos:Distance( trLeft.HitPos )
				dist = math.Round( dist )
				local midDist = ( dist / 2 )
				-- Trace to find where the middle point is.
				trMid = util.QuickTrace( trRight.HitPos, apRight * - midDist, { ply, ap } )
				newPos = trMid.HitPos
				newPos.x = math.Round( newPos.x )
				newPos.y = math.Round( newPos.y )
				-- Sets the new position (middle of the distance)
				ap:SetPos( newPos )
				-- Sets the variable so the collision of the area portal is set on it's ENT:Initialize()
				ap.cMin = Vector( -midDist, 0, 0 )
				ap.cMax = Vector( midDist, 0, gamemode.AreaPortalHeight )
				ap:Spawn() -- Spawn that mofo shit shock
				ply:ChatPrint( "Dungeon Edit: Area Portal [###] set at location: 

" … tostring( newPos ))

			else -- If it doesn't find any near walls, remove the area portal
				ply:ChatPrint( "Dungeon Edit: Failed to spawn Area Portal

Reason: Couldn’t find near walls." )
concommand.Add(“dgn_create_ap”, CreateAreaPortal )

In short, if you didn’t understand the problem itself, rotating the entity DOES work but doesn’t rotate the OBB (Collision Bound) which is stuck at a 90 degree angle…

Maybe the :Touch function uses AABB bounds? Otherwise I’m clueless:confused:

I’m still clueless, I don’t know why it doesn’t freaking work…

OBB is just a box between the lowest extreme and highest extreme. It doesn’t rotate it based on the entity’s rotation.

There’s no way to make diagonal bounding boxes?

Wait. You say you’re using OBB, but you do SetSolid as a SOLID_BBOX ?



What is SOLID_OBB then ?

I don’t have any knowledge in collisions, but trying other solid modes would something I’d try.

What do you mean? A line from the lower bound to the upper bound would go diagonally through the object.

Woooooooooooooooooaaaaaaaaaahhhh I feel silly now, it worked perfectly.

After 10 posts and multiple blown minds we found the little sucker.