godot-docs icon indicating copy to clipboard operation
godot-docs copied to clipboard

Add page about Godot 3.x -> Godot 4 guidelines

Open qarmin opened this issue 3 years ago • 0 comments

Few advices which could be added to this page

  • Don't use if "string" or if [] , since Godot 4 not supports this
var str = "str"
if not str:
	pass

should become

var str = "str"
if not str.is_empty():
	pass
  • Try to use builtin project converter multiple times, to check what not works in Godot 4 and what needs to be changed in Godot 3.x to simplify later conversions(this will also help to unify codebase between Godot 3 and Godot 4)
  • Use SceneTreeTween instead Tween - In Godot 4 old tween class is removed and SceneTreeTween becomes Tween
  • Some Control methods in 3.x are available in Godot 4 under Window class which not inherits from Control which may require to change a lot of code(not sure if there is any workaround for this)
  • Wrap some functions which returns String, with String():
var translation_key: String = name.to_lower()

works fine in Godot 3, but cause this problem in Godot 4

Cannot find property "to_lower" on base "StringName"

to fix problem just wrap name.to_lower

String(name.to_lower())

godot issue - https://github.com/godotengine/godot/issues/64171

qarmin avatar Aug 20 '22 19:08 qarmin