Delays in Collide events (Python)

I want to add a delay into a collide event, except the normal method of adding the wait time to game.time and then saving it as a variable doesn’t work due to it being a collide event.

I am on Game development 3 Final Project, and my code is here:
hero = game.spawnHeroXY(“captain”, 40.2,54.7)

game.addDefeatGoal(10)
game.addSurviveGoal()
game.addMoveGoalXY(40.2, 54.5)

right = game.spawnXY(“forest”, 46, 59)
right2 = game.spawnXY(“forest”, 46, 53)
down = game.spawnXY(“fire-spewer”, 40, 53)
left = game.spawnXY(“fence”, 36, 53)
left2 = game.spawnXY(“fence”, 36, 57)
up = game.spawnXY(“fire-spewer”, 40, 57.5)
game.spawnXY(“fence”, 36, 30)
game.spawnXY(“fence”, 36, 25)
game.spawnXY(“fence”, 36, 20)
game.spawnXY(“fence”, 36, 15)
game.spawnXY(“fence”, 36, 10)
game.spawnXY(“fence”, 36, 5)
game.spawnXY(“fence”, 36, 0)
game.spawnXY(“fence”, 44, 30)
game.spawnXY(“fence”, 44, 25)
game.spawnXY(“fence”, 44, 20)
game.spawnXY(“fence”, 44, 15)
game.spawnXY(“fence”, 44, 10)
game.spawnXY(“fence”, 44, 5)
game.spawnXY(“fence”, 44, 0)
game.spawnXY(“fence”, 56, 30)
game.spawnXY(“fence”, 56, 25)
game.spawnXY(“fence”, 56, 20)
game.spawnXY(“fence”, 56, 15)
game.spawnXY(“fence”, 56, 10)
game.spawnXY(“fence”, 56, 5)
game.spawnXY(“fence”, 56, 0)
game.spawnXY(“fence”, 64, 30)
game.spawnXY(“fence”, 64, 25)
game.spawnXY(“fence”, 64, 20)
game.spawnXY(“fence”, 64, 15)
game.spawnXY(“fence”, 64, 10)
game.spawnXY(“fence”, 64, 5)
game.spawnXY(“fence”, 64, 0)
game.spawnXY(“fence”, 16, 30)
game.spawnXY(“fence”, 16, 25)
game.spawnXY(“fence”, 16, 20)
game.spawnXY(“fence”, 16, 15)
game.spawnXY(“fence”, 16, 10)
game.spawnXY(“fence”, 16, 5)
game.spawnXY(“fence”, 16, 0)
game.spawnXY(“fence”, 24, 30)
game.spawnXY(“fence”, 24, 25)
game.spawnXY(“fence”, 24, 20)
game.spawnXY(“fence”, 24, 15)
game.spawnXY(“fence”, 24, 10)
game.spawnXY(“fence”, 24, 5)
game.spawnXY(“fence”, 24, 0)
game.spawnXY(“fence”, 40, 30)
game.spawnXY(“fence”, 20, 30)
game.spawnXY(“fence”, 60, 30)
inputm = game.spawnXY(“x-mark-stone”, 40, 3)
inputl = game.spawnXY(“x-mark-stone”, 20, 3)
inputr = game.spawnXY(“x-mark-stone”, 60, 3)

def onCollideLeft(event):
unit = event.target
other = event.other
if other.type == “fence”:
spawnedl = game.spawnXY(“fence”, 20, 3)
spawntimel = game.time + 0.2
unit.pos.x = 40.2
unit.pos.y = 54.7
else:
pass
pass

hero.on(“collide”, onCollideLeft)

Welcome to the forum @Ethan_Galinger ! :partying_face: This is a friendly place where you can ask help on levels, report bugs, or just chat with other coders! Don’t forget to read the guidelines if you haven’t yet. Have a great time!

Please can you post your code formatted using this button, we’d be happy to help:

3 Likes