Issue with Unixtime

Godot Version

4.2.2

Question

[SOLVED]
**This has caught me out before. It has nothing to do with Unix time. It is because you have to call super() in the derived _process() function even though the base _process is marked as a callback from the Godot engine. You think it is being called by the engine but it’s not - you have to call it explicitly. **

I have an issue with get_unix_time_from_system(). In a minimal test project, I have a base class providing an age value based on UNIX time. The ‘start_time’ is established in _ready() and the current ‘age’ is updated in _process. Using ‘age’ in a getter function always returns 0. However, if I update the age value directly from the getter using get_unix_time_from_system() it all works fine (see the line commented out).

What is wrong with updating in _process only and returning the age value from a getter rather than updating the age in the getter?

BaseClass

class_name Entity
extends Node2D

var _start_time: float
var _age: float = 0.0

func _ready() -> void:
	_start_time = Time.get_unix_time_from_system()

func _process(_delta: float) -> void:
	_age = Time.get_unix_time_from_system() - _start_time
	pass

func get_age() -> float:
	#_age = Time.get_unix_time_from_system() - _start_time
	return _age

Simple test class

extends Entity

func _process(_delta: float) -> void:
	print("age = ", get_age())