What are some ways to indicate an Actor has stopped moving?

I’m currently setting up an Enum for the player ‘state’ to help with the game logic (So that the game will know if the player is moving, attacking, etc), but I’m having trouble determining the difference between ‘Idle’ and ‘Moving’, or rather, going back from ‘Moving’ to ‘Idle’.

Currently when the player sends any inputs to move that are valid, the character will change from whatever state they were in to ‘Moving’, but I can’t seem to figure out a reliable way to find out if a player has stopped moving so I can swap them back to ‘Idle’ again.

The closest method I have found is to request the player’s velocity and check that against a pre-defined FVector that would represent no movement, but doing that every tick isn’t really ideal. Any suggestions regarding this?

#CharacterMovementComponent

You should check out CharacterMovementComponent.h !

And you can access it this way

MyCharacter->CharacterMovement

All the data you want is there

like:

hmmm

okay nevermind

I could not find any “CurrentSpeed” equivalent :slight_smile:

#What I do

make a boolean and make it global and set it via the below every tick

#SizeSquared()

it is more efficient than using Size(), but that’s the as good as I know how to make it

if(MyCharacter->CharacterMovement->Velocity.SizeSquared() < 5)
{
  //character is not moving
}
else
{
     //Character is moving

 }

Hey Rama, thanks for the input!

That’s quite similar to what I had attempted but I encountered a problem with both my solution and yours - it’s causing my game to crash:

With _C being defined as:

7835-ss+(2014-06-05+at+05.52.43)6.png

I’ve been trying to work out why that is but no solutions as of yet, any input?

Ah okay, the issue seems to be the definition of ‘_C’, replacing that with ‘GetCharacter()->’ worked fine. Hooray!