Trouble detecting collision with copy of object

Hello!

I’m having trouble detecting collision with a copy of an object that is being stored in a variable. Sometimes the collision is detected, sometimes it’s not.

Here’s the code for reference:

If I press the space key slowly and bounce objects off of the wall one at a time, the collision doesn’t register. However, if I press the space key quickly, I’ll start to get detections.

Here’s a remixable CoSpace example: CoSpaces Edu :: Throw Ball

Appreciate any help!

  • Jordan

You should put a a run parallel code block under: when space key is clicked. Like so:

Hopefully that solves your problem.

1 Like

Hi @hw-jordan,

The CoSpaces Debugger is your friend here. If you play your CoSpace and watch it, you’ll see that there is a delay between the push block and the event firing. Therefore, simply move the event to just after your set variable block - this way, the event listener starts listening as soon as the new ball is created.

Hope that helps! Let me know if you have any further questions about this. If this solves your problem, please mark this post as the solution.

Many thanks,
Geoff @ TechLeap

PS: @Jurassic_P_Ark run parallel could possibly cause problems in this case, as the event listener may register before the ball copy is created, and would therefore apply to the previous ball.

1 Like

Thanks for the help! Both solutions worked, but as Geoff mentioned, the run parallel could potentially cause issues.