Collision detection doesn't work

Hi. I’m making Pacman game and having a problem in collision detection.
When the camera collide with yellow balls(gold), it recognizes the ball and acts as the way given in function(sound/disappear). By the way, when the camera collides with enemies (squares), the function doesn’t work. here’s my code.

link : CoSpaces Edu: Make AR & VR in the classroom

Hi @Joy,

the link to the space you shared is your private link, which can not be viewed by other users. Please use the share link instead. If you do not see the share link, the teacher has to unlock that ability it for you.

Looking through your code, everything should work as intended. Here’s a checklist to make sure the collisions work as expected:

  • Are your items named enemy1, enemy2 and enemy3?
  • Are your enemy items tall enough to reach the camera? When the items are not tall enough, collisions do not count sometimes. Try playing with the enemy size

I got “Access denied”

Hello, @Stefan
Sorry about that.

Here’s the link

Hi, @mariochiesa
Sorry about that.

Here’s the link

Hi @Joy,

Thanks for sharing! I’ve looked through your code and noticed that you’re trying to set set two collision event handlers on the enemy items. Please keep in mind that only one collision handler of a particular type can be active at the same time.

Please take a look at this answer from another thread to see how event handlers work in CoSpaces :slight_smile:

There are two solutions for your problem:
a) Set an event handler on the camera item and check if the item which the camera collides is one of the enemies.

b) Add the game over - logic to your movement script.

Below you find an improved version of your pac man space. Check out the scenes “solution a)” and “solution b)”. Click the remix button to copy the space as your own and check out the code!

1 Like