How to find the coords of the position to the left or right of a player

Hi, I’ve got an action where I create an effect in front of a player, but I also want to create an effect diagonally to the left and right in front of him as well.

It seems so simple but I’m feeling kinda lost. I take player position, add facing direction of * some small number, then… I dunno, move it to the left? I can’t figure out how to get player left and not world left.

There are actually multiple ways to do so.

A general but unnecessary complicated way would be to rotate the vector by an angle using a rotation matrix: https://en.wikipedia.org/wiki/Rotation_matrix

You can make your life easier though by using “world vector of”. Players have their very own coordinate system. This coordinate system is fixed on the player and rotates whenever the player rotates. So vector(1, 0, 0) in the local player coordinate system is to the left side of the player. Vector(-1, 0, 0) is to the right, vector(0, 0, 1) is forward and vector(0, 0, -1) is backward.

If you want to get the world vector of the vector to the forward but slightly to the left aswell, you can use world vector of(vector(1, 0, 1), event player, *wildcard*). Replace wildcard with “rotation” if you want to use it as direction and replace it with “rotation and translation” if you want to use it as position.
You could also add some vectors like this world vector of(left + forward, event player, rotation) wich gives you the same result.

1 Like