How to detect if the player is not moving

Hello there! I am having a problem with my javascript code. I want to make a code that detects if the player is moving, and if he does not move for example for 15 seconds, to respawn him at the original starting position.

Assuming that you are the one who makes the player move:

Have a float variable, e.g. float last_move_time;

Whenever you move the player, set last_move_time = Time.time;

In your Update() function compare last_move_time to Time.time. If the difference is more than 15 seconds, you have your condition to respawn the player.

(I was using C# class names, i hope the JS names are identical or similar)