Swapping objects from different layers at key command realtime

Hullo

I am creating a game where you click to spawn balls that bounce on a keyboard to play melodies/notes. Currently there are two types of balls, one which spawns on click in a certain area, and one which, when created, remains static and spawns balls automatically at a specific rhythm.

I want to create a switching system using the keyboard numbers to switch between these two types of balls (1, 2). However, all attempts to do this have led to no avail. I’ve tried to set the state for them using the logic bricks, ending the active one and using addObject to get the other one, etc…

I’m really stuck with this, so any suggestions would be much appreciated :slight_smile:

Link on google drive —> LINK: https://drive.google.com/open?id=1mV1FSbuNumMKOhnjdbFyywtAnldNxFrO

Nice Game can’t wait…

1 Like

autospawn mode stage 1_with_ball_switch.blend (4.2 MB)

1 key (default) left click to add ball
2 key ball get’s added every second (depends on delay sensor)

BTW, this file needs cleanup, errors crashes out of nowhere, all kind of stuff trying to add something that don’t needs to be added etc. but that’s not up to me, added a tiny script and redone your presentation object. also removed some l click commands from the spawned sphere, and you use the same sphere in both states now.

Have fun with it, nice concept btw.

1 Like

Thanks very much! However, the idea was to create static balls that did the autospawning, and that the balls would die after hitting the keyboard…
…but the script has given me some ideas on how to achieve this, so thanks anyway :grinning:

There are a lot of errors still as you said, and very messy script and object collection. I will neaten it up before publishing though.