godotengine / godotengine/godot-docs

Confusion about "inheritance": parent-child and OOP

Open
#2,888 2 comments 1 reaction 0 assignees View on GitHub
area:manual content:new page discussion
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

I feel as though I've read the docs fairly carefully, and this difference (especially as a new programmer) doesn't feel explicit enough to me:

**What's the difference between a child inheriting its parent's transform (e.g. if a Sprite is the child of a KinematicBody2D, it moves with the body) and Node2D inheriting from CanvasItem?**

My incomplete understanding is: the latter (Node2D inheriting from CanvasItem) is inheritance in the OOP sense. The former is "inheritance" as in "a few select properties get passed down from parent to child".

All I know is that there's a difference, but I don't know exactly what it is.

A few more points:

1. This confusion could stem from the word "inheritance" being used in two similar-but-different situations.

2. Another way this question could be phrased: **what does it _really_ mean for a node to be a child?** OOP concepts like aggregation are mentioned.

3. My experience in reading the docs is that this relationship is always mentioned, and from working with godot, the difference is absorbed--something just clicks eventually.

If I just completely missed this somewhere in the docs, my apologies.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.