Skip to content

Node References / Scene Hierarchy#7

Open
DavidMWright wants to merge 2 commits intoKenneyNL:mainfrom
DavidMWright:node-references
Open

Node References / Scene Hierarchy#7
DavidMWright wants to merge 2 commits intoKenneyNL:mainfrom
DavidMWright:node-references

Conversation

@DavidMWright
Copy link

Node References

  • onready's replaces with exports
  • Added categories and groups to exports on vehicle
node_references



Reasoning:

  • Using exports to reference nodes makes it much easier to swap components out, only needing to select from the scene tree rather than having to retype the full path
  • Leverages using the editor to configure the game, rather than hard-coded references in script
  • Groups and categories added for additional organization and built in documentation



Split vehicle into it's own scene

  • Updated Vehicle script to be it's own class
  • Added public function to get position
  • Updated vehicle function names to align with Godot style guide
vehicle_scene



Reasoning:

  • Allows for easier editing of the vehicle itself in editor. Won't have to deal with clutter from the main scene
  • Splitting Vehicle into it's own scene makes it easier to duplicate and re-use later (multiplayer, NPCs, etc.)
  • Defining Vehicle as a class allows for code completion on function calls
  • Creating a public function for the position ensures Vehicle has ownership on how this data is passed if the vehicle's physics / control is changed later down the line
  • This coding style is not only standard in Godot's docs, but helps prevent programmers from using internal only functions, as Godot does not have real private membership restrictions



Updated view script

  • Calls new public Vehicle function to get position over the direct reference

Reasoning:

  • Decouples the camera and vehicle

DavidMWright and others added 2 commits March 15, 2026 12:16
…oups to exports on vehicle. Split vehicle into it's own scene. Updated Vehicle script to be it's own class and added public function to get position. Updated view script to call new get position function. Updated vehicle function names to align with Godot style guide (public vs private functions)
@DavidMWright
Copy link
Author

Forgot to mention, all functionality has stayed the same. Purely organizational and structure changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant