Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(2 edits) (+1)

Previous export tip supercharged: here's export for referencing a node in the node tree:

export(NodePath) onready var player = get_node(player) as KinematicBody2D
  • Create a variable and assign it
  • Follows static typing - you get nice class-specific hints in the script editor instead of useless garbage
  • No need to remember how your node tree is laid out
  • You can rename or move that node elsewhere on the tree and it'll still be connected
  • All of that in one single line

The only downside to this is that it doesn't play nice if your script is a tool script. Other than that, it's super useful if you're a diehard OOP follower or rely on singular nodes to do your bidding instead of making one giant script for readability.

And here's a load and preload alternative with the use of export:

export(PackedScene) var bullet_entity

No need to refactor your code if that file moves! If you use Godot's file system to move files, other scenes should update automatically with the new file path.

Hmm I did not know about PackedScenes being compatible, Thank you.