You have a few options:
1. Have it as a function and call it every frame as part of your core components.
2. Have it in your entity's actions.
3. If common, have it as a separate function and call it every frame.
You do need to assign the pointers as necessary. Player assumes the player character. It could also be the camera, especially in first-view perspective. nonmovingentity refers to the entity that doesn't move. If within the entity's action (for the nonmoving entity), you could have "my.x" instead of the longer name. The longer name is used when the first option is chosen (which is the best option as you can have my.dynamic = off; for the entity to speed up the frame rate.