So here’s the deal, I made an entity that slides from point A to point B and back, based on a “base” entities position.

The base, is a 4x4 prop_physics wall, and the ent is a 3x3 prop_physics wall.

Now, what I’m trying to do is grab the base’s position, and find the positions of two opposing corners.

Then, I need to find a vector point between those two vectors that changes based on time.

I already did all of this, successfully, the only problem is that I used a static vector offset added to the base’s position with the Angles set to (0,0,0) on the base.

So when I would rotate the base and try to calculate it, the points would be wrong because the corner’s position offset change with the yaw rotation.

So I’m left with two options, snap the angle to the nearest 45 degrees and use more vector offsets that vary

OR

dynamically calculate the positions of the corners and variable point between them.

I want to do the latter if possible.

The only reason I’m asking facepunch is before I do a lot of unnecessary math and complicated equations, is there a simple way to achieve this?

Here’s some example code of what I plan to do with this code.

I plan on moving the 3x3 across the 4x4 from corner to corner, based on time (like a sliding feature)

My original code has a pretty large scope, so this is better.

[lua]

local mul = math.cos((math.pi * t) / 2) – where t = time

local x = 23.725402832031 * mul

local y = x * -1

sent:SetPos( base:GetPos() + Vector(x,y, 0) ) – 11.899916887283 originally

sent:SetAngles(base:GetAngles())

[/lua]

So to summarize, I know the base’s position, i’m trying to move the ent sitting on top from corner to corner over time.

The corner positions change when you rotate the yaw angle (clockwise movement) so a one-size-fits-all vector offset won’t work.

I need to find a dynamic way to calculate the offsets and find any given point between that range.

Here’s a visual aid to show what I’m talking about also.

Yes, I know it’s a crappy paint png.

Another note is that the base will always be flat, so the only angle that concerns us is the yaw angle.

Thanks Facepunch, if it wasn’t for you guys I’d probably be raking the shattered remains of this monitor into the trashcan right about now.

[editline]11th August 2017[/editline]

[editline]11th August 2017[/editline]