Hi everyone, is there a way to detect whether or not a gameobject is moving? I would like to detect if the FPS Controller from Unity’s Standard assets is moving.
I guess an algorithm could be
Store the players world position in some variable
Every frame compare the position to the start position of the player.
if the players position is now different from the start position, the player has moved
set the new position of the player as start position for continious movement detection
Something like this I guess…
What in this new position detects the player though? We’re still back at square one.
function Update(){
playerPos = player.position;
if (playerPos != lastPlayerPos){
///player has moved
doSomething();
}
///update last player pos
lastPlayerPos = playerPos;
}