How to detect direction of player when going to wall

Hi,

I have a simple wall and I have to detect in which direction is player approaching the wall.
I dont have to know precise angle or something, just if player is going from right side or left side.

How can I compute this please (without using two other triggers)?
Thank you

Works, if the player moves in the direction of the wall:
you can check the velocity of the player
you can raycast towards the players movement direction and then checking hit.normal (hit is the HitInfo)

works every time:
if the wall is not in a weird angle, then checking the difference between the players and walls x/z position
creating a vector starting from the wall and going to the player, and checking it’s direction

there are a lot of ways to do that

It will be far more helpful to state your purpose for this, to evaluate if you are using the right solution at all.

Thank you, I did following:

Vector3 diff = wall.position - player.position;

And I looking to diff.magnitude but Im not still sure how can I determine from magnitude the “right” and “left” side.
Because the magnitude is affected by distance of those two objects and the “center” value (when player is looking to the center of the wall) is never zero, only when player and wall have same coords.

When I move player to the right I get some valid value but the value is exactly the same when I move the player to the left by same length (and both are affected by distance of two objects). So I cant determine if its left or right side of the wall.

I think I still missing something…

EDIT: To “discard” the noise caused by distance of wall and player, I can do the “diff” only on specific axis, which will do the job but only for specific walls. When wall is rotated, this solution seems to be bad.

Yes, indeed, magnituude is something like the length of a vector, convert it to local space and check, the x and z coordinates