Moving AI against the wall of his direction

Hello!
Recently I’ve stuck on one problem making AI for NPC in my game.
The problem is, I can’t figure how to get perpendicular direction against wall, but at the side where NPC has moved.
Here is what I trying to achieve:
image (11)
Feel free to ask question, I’ll try to answer!

1 Like

once you casted the ray and it hit the wall, try this

local direction = rig.HumanoidRootPart.CFrame.LookVector * 50 -- This is the direction im using, change this to yours
local perpdirection = direction:Cross(Vector3.new(0,50,0))

:Cross just returns the perpendicular vector between two vectors. The perpendicular direction isn’t going up into the sky so we use that as the parameter

And I got this.
image
Ray not going like on this screenshot, it’s opposition of what I trying to achieve
image

1 Like

Never mind, I’ve just fixed this problem :smiley:
Just remain to get dot product of character direction and orthogonal direction, and multiply orthogonal direction by it.

Um ok… what is orthogonal direction? Just asking

The perpendicular vector I’ve mean.

I was experimenting with Cross just now so Im still quite new to it

1 Like

Me either, this is my first time doing this kinda stuff :smiley:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.