0 votes


everything was working fine until I added another kinematicBody2D

the later was used as the default player

how do I select the default player kinematicBody2D

  • on startup
  • programmatically during the game ?


Godot version 3.3
in Engine by (36 points)

1 Answer

+1 vote

Godot doesn't have a default player or anything like UE4's game mode options (if that's the kind of thing you're looking for).

You will need to either need the player script on both and use a bool that allows control or a separate script e.g. a singleton aka autoload script that holds all the references of existing players in an array and selects the player using an int.

by (3,225 points)

well it obviously does since it's choosing between one the two kinematics...at least around the camera used by default

how do I set the wanted camera to be used ?

also if there are many cameras,

how do I address them programmatically ?

they are just called Camera2D, I would need some identifier to use at programming time

can I get an array of available cameras and a tag to identify them somehow in the script ?

That's the current property on the camera, not a selected player option. If another Camera has current set to true it overrides the last camera being used.

Yes, in Godot tags are called groups and get_tree().get_nodes_in_group("group/tag name") returns an array in the scene hierarchy order.

It's also worth noting that Godot doesn't use a GUID system until runtime which means references are made in the editor and scripts by NodePaths that need to be passed through get_node() at runtime to return the actual node.

is there a way to have a startup script (global to the game/level) so I can setup things ?

Yep, go to Project > Project Settings > Autoload tab. In Path choose the directory of a script and Node Name is the reference name that can be used from any other script.

ok I found how to use singleton and project settings
thanks for your help guys

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 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 webmaster@godotengine.org with your username.