evaera / matter

A modern ECS library for Roblox.
https://eryn.io/matter/
MIT License
144 stars 34 forks source link

ChangeRecord behavior right after deletion #70

Closed Insadem closed 9 months ago

Insadem commented 9 months ago

Remark: record is of type ChangeRecord.

Current behavior: record.new might be nil even though record.old is nil too. This will happen if you spawn and then despawn entity right away in the same frame.

Presumable behavior: record.new will be populated, record.old will be populated. Maybe even better to run for once queryChanged with new, and then with old data.

My thoughts: I'm not sure whether it's intended, but from my P.O.V it's not intuitive behavior. However I do understand that it might become even more confusing if you change current behavior, but at least documentation of current behavior would be great.

LastTalon commented 9 months ago

This is intended behavior and it's documented with ChangeRecord. If both are nil that indicates that since queryChanged last ran it was both created and destroyed. It would be incorrect to populate either field in that scenario; the last time you saw the state of the world it wasn't there, and in the current state of the world it's not there.