Need a little help

Hi guys

I need help with one my game game design whereby if you interact with an object a small mini-game on small window will show up, I don’t know to get it done, or is it even possible?

So basically an object when interacted with a button will trigger to make a small window on-screen and will show a mini-game like tic tac toe in-game.

I’d do it this way:

  1. Add your button sprite object to the scene inside the area seen by the main camera.
  2. Add your minigame related window and asset sprites to the same scene but somewhere far off the camera view.
  3. Put the minigame stuff on a new layer
  4. Add mouse button released and mouse/touch is on object condition to your button.
  5. Add an action to center the camera on an object to the button. Pick your minigame window as destination and choose camera 0 on the new layer
  6. by clicking on the button the minigame gets overlayed on top of your game.

Hint:
You can easily crate a slide in animation in “5)” if you move the camera above, unter, left or right of the minigame window and then use a force to move the camera towards the window (or use the “lerp” function from the math expressions for smooth transition). It will look as if the window slides in even though you are just moving the camera.

Thanks Wendigo for your reply!, I’ll go try it out!

So basically this is what I did so far, I’m doing something wrong because whenever I press q it doesn’t center the camera to the mini-game, why is that? :confused:

By the way, I don’t want to use clicking, but instead on button press.

What I’m trying to do is, When the player is touching the door, and then if Q button is pressed, the mini-game should appear.

Not sure if it got anything to do with the problem you have, but only would like to point that out to my knowledge pixel perfect collision checking is deprecated in GD5 and also it was not accurate last time I tried. Consider collision checking with mask or check distance instead.

It also seems to me you are constantly center the camera on the player and hide the Mini-Game layer it might cause your problem. You may want to add a variable or something to make sure it triggered only once, maybe center the camera on player only if the mini game layer is NOT visible and hide the mini-game layer when the player is not in the mini game and show it when the player is entered the mini-mage, you can use a variable to create a state machine for that.

As ddabrahim said, the problem is that you hide the minigame layer every frame. Also pixel perfect is exactly the same as using collision masks, as you can read here: SpriteExtension.cpp#L86-L93

I’ve made a minigame example here:
Minigame.zip (17.4 KB)
Press “Spacebar” while colliding with the machine thing (not sure what the image is) to enter the minigame, make clicks to move the ball. You can exit the minigame collecting all the stars or pressing “Z”. Note that the player can’t move while on the minigame and the minigame shouldn’t run when outside because the “minigame” variable, a state variable as ddabrahim suggested.

Use a “At the beginning of the scene” or “Once while true” conditions.

Thanks for the awesome reply guys! I’m sure I’ll get it to work now, especially to Lizard-13 for the detailed example thanks a lot. :slight_smile: