Hundreds of features to explore
Games made in Construct
Your questions answered
Popular & trusted by schools and Universities world-wide
Construct 3 runs in the browser & works offline
Students do not need accounts with us
Our educational partners
Free education resources to use in the classroom
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
So I have an infinite runner where the player moves along to right. The Player is a Physics based object. So it is possible for the player to move backwards. I need a way to keep track of how far the player has moved along the X axis. How would I track that?
You can have a variable to store the time of moving.
Then when the player starts moving, you add dt to it.
When the game over, stop adding and you have the distance = player speed * time of moving.
Okay I understand in concept, but how would I construct that syntax wise. Snice it's a physics object, I'm not sure if the variable for current speed would have to be tried to the object physics velocity.
You don't have to worry about time at all. You can literally just count x pixels moved.
Have a variable that stores the last x position, and total distance travelled.
Set distanceTravelled to currentX-lastX
Set lastX to currentX position
Okay so I have the variable recorded like this
CurPosition - Every tick: Set Value player.X
Then how do I record it's last X position so I can match your post?
Develop games in your browser. Powerful, performant & highly capable.
set distance to player.x + player.oldx
set oldx to player.x
if you write them in that order it will calculate the distance travelled
Okay so I make two variables, Distance_Traveled and oldx
Then every tick set oldx to player.x? Cause player.oldx gives me a syntax error.