I want to make a Node structure for various purposes in my game, and i’m getting cyclic problems.
I’ve tried numerous variations on this structure, but I always get errors. This includes turning doing “Node *parent” instead. Should I make it a new class instead? But wouldn’t that also be less efficient?
Structs are value types, not reference types.
Node parent gives you a completely new value for parent, not a pointer to the parent node. You most likely want to use a class for self-referencing objects.
Performance is likely not a problem (although you may need to use object pooling at some point to avoid garbage collection issues). And you should only worry about performance after you’ve used the profiler to identify areas of the code that are causing performance issues.