0 votes

Hello.
I'm currently doing a Pong game, and I think I got a pretty nice result, but I'm having two problems finalizing it:

  • I have a Main Menu scene, with some button options (1P that goes into easy/normal/hard ptions; and a multiplayer option). From this Main Menu scene, the game goes into the Game scene. But I don't know how to change some parameters from some objects in the game, based on what I press on the previous scene (the main menu)
  • For example, the main state of the game is what I would consider the "easy" option for 1P. But if I click on the normal or hard option, I don't know how to affect directly the speed of the ball and the speed of the AI on the code.
  • There's a similar problem for the 2P option. The main state of the game is with a pretty basic AI, but if I click on the 2P option on the main menu scene, I don't know how to alter the code of the enemy to change it to only a controllable sprite, without my AI code.
  • I know how to make a controllable sprite for the second player, or to speed up the ball on every collision, or increase the A.I speed, I just don't know how to do this "exchange" of code based on what I press on the previous scene.

I could avoid all of these questions by having a new scene for all the options (1P/Easy, 1P/Normal, 1P/Hard, and Multiplayer), but I don't think this is a wise choice for organization and optimization.

Thanks!

Godot version 3.4.4 stable
in Engine by (12 points)

1 Answer

0 votes

You need to have any script, that persists through menu scene and game scene. All persistent data should be kept in such a script.
You can create a game menager scene, that resides in highest scope, and has menu and actual game as children. Or You can create autoload script.

by (7,742 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.