Sensing Camera Movement

I’m trying to make red light green light in cospaces. So how do I code it where if there is camera movement when the traffic light is red it should restart the scene? (I need replies asap thank you!)

You need to place an invisible barrier beside the light, then use a collision coblock to detect if the camera has broke the red light.

I hope it helps.

Hi @unkown,

To solve this, the main question we need to ask is: how can we tell that the camera is moving?

This may depend on the device - on a laptop we use keys to move, so we can use the on key pressed events. This may not work in VR/mobile though.

To do this in a cross-device way, we would need to instead check the change in camera position over a small amount of time, for example, store the camera position in a variable and check the camera position after 0.2 seconds and compare them.

Hope that helps! Let me know if you have any further questions about this.

Geoff @ TechLeap

Can someone help me with a little bit of the code for the camera sensing movement. I am pretty new to this program and am a little confused. Thanks

What are you trying to do?


I want to make it so that every time the player moves when the Red Light, Green Light music is not playing, the scene restarts or ends. So basically while the music is playing, the player can move towards the finish line. But when the music stops, if the player continues to move towards the finish line then they will die and the scene will restart or end

Ok, i understand, try this code.

1 Like

I don’t think it worked because I copied it into the program but when I played the game, it kept ending the scene whenever I moved. I want the music to play, and while the music is playing you cannot move. After the music ends however, you can move until the music starts playing again. Thanks!

If you want, I can share the project with you so you can test it

Okay, if you send me the cospace i will remix it.

I created the working version of green light red light.


Thank you! I have used a sample of your code and customized it to fit my scene. I’ll send a link once I have put the finishing touches on the scene so everyone can test it out. In the meantime, could you maybe help me with my next step for my game. I want to create the honeycomb game mode from Squid Game where players have to cut/trace out a cookie and if the cookie breaks then the player dies. I am aiming for cookies in the shapes of a star, circle, triangle, and umbrella. I don’t know if it is possible to make a game mode where you have to trace out a shape and if you mess up, you die but I want to try to create this.

1 Like

Okay, i’m going to try to create that.

1 Like

Squid Game
That is the link to the game^^

The Honeycomb gamemode code works really well and I made it fit into my scene. I only need help adding one thing. When the player finishes tracing out the shape without failing, I want to bring the player back to the “Start Scene.” I also want to add a life system of 3 lives. If the player uses all 3 lives, then they will also be brought back to the “Start Scene.”

I can’t find the cospace with your link

Please create a new topic, later i’ll try helping you