Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to get character's moving direction in relation to the world?

I want to understand how I can know whether the character is moving backwards or forwards in relation to the world.

Let me clarify a bit on what I have done so far. Using MasterControl:GetMoveVector() module, I get a Vector3 with 0,0,1 if moving forward or 0,0,-1 if backwards- but the catch is that this is in relation to the camera. A user can be travelling backwards with camera facing forwards and I want to catch this.

My current solution is to get the player's current coordinates and the player's coordinates after they move to answer my question but surely Roblox has a better answer in place.

1 answer

You could get the velocity of one of the characters parts. Then just check if X or Z is positive or negative.

1 comment

0

As far as I know, this will work in the way that I described - if I walk using forward arrow key, i get a positive (0,0,1) and if i walk using backwards arrow key I get a negative (0,0,-1). This is relative to the camera and I don't want it. What I want is walking backwards or forwards irrelevant of the camera angle.

This discussion is preserved as it was. New answers, comments, and votes are closed.