Physics on collision not working

I am making a glass bridge game based on Squid Game in CoSpaces. I’ve made it so when the camera collides with one of the glass panels, physics turns on and the glass panel falls. However, the code doesn’t work and nothing happens. Here’s a video of me playing the game with the code on the side:


I have also tried removing the forever loop, and that just does nothing.

Hi Gorillamonkeybanana,

I would start with physics enabled on the glass panel, and set static to “on.” Then, when the player camera collides with the glass panel, just set static to “off.” See the screenshots below. Let me know if you have more questions!



Screenshot 2024-12-08 134348

1 Like

Hi, @BRIC,
I tried the code and it didn’t work. However, I had another CoBlocks script running a forever loop, and removing that enabled the glass pane script to work. Now I’m wondering, can I have 2 forever loops running in different scripts, or do I have to use the run parallel block?

Hi Gorillamonkeybanana,

You can absolutely have forever loops, just use a “run parallel” block or put them inside of a “run separately” block so they do not pause the rest of your code while they play.
Screenshot 2024-12-10 090253

Unfortunately, the code still doesn’t work.

Hi Gorillamonkeybanana,

Can you share your project and post a link here so I can remix it and look at the code? Alternatively, can you screenshot your code and upload it here as an image?

Sorry I haven’t replied in a bit. Anyways, here are the two code panels:
Screenshot 2024-12-14 5.02.07 PM
Screenshot 2024-12-14 5.03.50 PM

Hi Gorillamonkeybanana,

Here is an example cospace I made showing how to use the “when” statements. You do not need to put those into “run separately” or “forever” loops. “When” statements are always listening for the event. I have also pasted the code below, in case you do not want to visit the cospace. Please let me know if you have more questions!

How do I properly set up collision detection?

Hi Gorillamonkeybanana,

Are you referring to the physics collisions? Right-click any object you want to have physics enabled on it, click over to the “physics” button, and turn on physics. If you want an object to remain stationary in the scene and not fall due to gravity, turn on the “set static” slider. If you want platforms to fall once the player stands on them, you can toggle that “static” toggle off with a line of code (see an above post).

Any object that has Physics turned on will interact automatically with any other object with physics set to “on.”

I hope that helps!