Getting position sides of target

Hi all, hope you are having a great day so far. I need some help on something that MAYbe is really simple, and I hope I’m just overlooking it. Anyway, it is really late but I can’t really wrap my head around on how to do this properly. I don’t usually ask for help, so I’m not sure if I’m doing this topic correctly, but ask more if you need something.

Let’s say I have two simple humanoids. I will call them Green and Red. Red being the enemy, Green being the good guy.

Now, lets say I got everything working, simple AI, Red approaches Green, then Red proceeds to beat up Green, your typical Roblox AI, nothing special. But here is where my problem starts. I don’t want Red to walk directly up to Green, but actually to his sides, relative to Red’s positioning. Want this kind of solution, where Red will walk to Green’s side:

Getting RightVectors for Green will be useless as well, since Green won’t always be facing towards Red. I tried using the direction between Green and Red and using that RightVector by converting it to a CFrame but to no avail. I hope this makes sense.

My only thought is, get the position of the green and the left vector of red. Then just add the specific amount you want to green’s position. It will always go to the same distance and to the left of red, just make sure you do the relative vector of red instead of the space.

1 Like

U can use pathfinding to go to a certain amount of studs in front of the green guy or use WalkTo.

local RedPosition = Green.PrimaryPart.Position + GreenGuy:GetPrimaryPartCFrame().lookVector * 5 -- Pathfind to this spot

RedGuy:SetPrimaryPartCFrame(RedPosition, Green:GetPrimaryPartCFrame().p) -- Use this at the end of the pathfind to make the red guy face the green guy