Hello, I am new to Blender and Python and I have to make a game for my school project. I am making a 2D platformer and I want checkpoints so when my character dies it doesn’t have to start again at the beginning of the level but somewhere in between wherever that checkpoint may be.
So I was thinking I need to have a Collision Sensor that detects if my character has passed a checkpoint. Then if it did it has to save its location in to an array that I can refer to when the character dies. I currently run in to the issue that it saves the player location when this collision sensor is active but the list is empty again as soon as the sensor is not active anymore.
My current code:
# Configuration senCP Attributes senCP.propName = 'checkpoint' senCP.useMaterial = False senCP.usePulseCollision = True # Status senCP Attributes hitObj = senCP.hitObject hitObjects = senCP.hitObjectList # Activate Checkpoint start = scene.objects ['Start'] checkpoints =  if senCP.positive: checkpoints.append(player.worldPosition) # This is just to see if the location is saved in the list print (checkpoints)
I run in to a couple of problems here:
- When I print (checkpoints) it only shows the player location when the sensor is active. After that (when the player has passed the checkpoint) the list is empty.
- I currently use a static object that detects collision as a checkpoint. However I want to work towards a system where the player is not interrupted by a collision because this might result in bugs like if the player repeatedly walks over the same checkpoint it might fall of the platform. I want to avoid that.
So I need help, you guys got any solutions or alternatives I can use here?