I check the first tutorial named dodge the creep and get one question, why main area use Node not 2d

origamiorigami Posts: 20Member
edited January 13 in 2D

The main scene use node not node2d, why is this? Will this 2d game use some 3d feature?

https://docs.godotengine.org/en/stable/getting_started/step_by_step/your_first_game.html#main-scene

Best Answer

  • xyzxyz Posts: 907
    edited January 14 Accepted Answer

    @origami said:

    @xyz said:
    You can add any node as a child of any other node. However in some cases functionality of a node may depend on its parent or children type(s).

    Can you give me a example about the functionality of child node affected by parents? A link will be enough, if it is convenient, thank you.

    One example might be the CollisionShape node. It needs to be parented to a physics body or area to function properly.

Answers

  • xyzxyz Posts: 907Member
    edited January 13

    'Node' doesn't have any 3D features. It's more basic than Node2D, higher up the inheritance hierarchy. Its functionality actually doesn't deal with anything related to 2D or 3D.

  • origamiorigami Posts: 20Member

    @xyz said:
    'Node' doesn't have any 3D features. It's more basic than Node2D, higher up the inheritance hierarchy. Its functionality actually doesn't deal with anything related to 2D or 3D.

    functionality actually doesn't deal with anything related to 2D or 3D.

    Gotcha the Node CanvasLayer is not child of Node2D. Thank you

  • origamiorigami Posts: 20Member

    @xyz said:
    'Node' doesn't have any 3D features. It's more basic than Node2D, higher up the inheritance hierarchy. Its functionality actually doesn't deal with anything related to 2D or 3D.

    Hi I found that if the parent node is Node2D, the canvas layer still can be added to it. Even though Node2D is not the parent node of canvas layer. So I am confused about your answer. If the node2d can replace the node in this tutorial ?

  • xyzxyz Posts: 907Member

    You can add any node as a child of any other node. However in some cases functionality of a node may depend on its parent or children type(s).

  • origamiorigami Posts: 20Member

    @xyz said:
    You can add any node as a child of any other node. However in some cases functionality of a node may depend on its parent or children type(s).

    Can you give me a example about the functionality of child node affected by parents? A link will be enough, if it is convenient, thank you.

  • xyzxyz Posts: 907Member
    edited January 14 Accepted Answer

    @origami said:

    @xyz said:
    You can add any node as a child of any other node. However in some cases functionality of a node may depend on its parent or children type(s).

    Can you give me a example about the functionality of child node affected by parents? A link will be enough, if it is convenient, thank you.

    One example might be the CollisionShape node. It needs to be parented to a physics body or area to function properly.

  • dotteddotted Posts: 347Member
    edited January 14

    Hi I found that if the parent node is Node2D, the canvas layer still can be added to it. Even though Node2D is not the parent node of canvas layer. So I am confused about your answer. If the node2d can replace the node in this tutorial ?

    There are two types of hierarchy, "type" hierarchy and scene-graph hierarchy. Type hierarchy is a lineage of properties (like color) and functions like translate(). A child of Node, like Node2D is a Node but has new properties and functions relate to them. Some nodes are type-children of others. Node is the base type of all scene trees. Node2D is-a 'child' of Node; Node2D has new properties and functions. Line2D is-a child of Node2D so it has its own unique properties (points) and functions.

    Scene-graph hierarchy is hierarchy of containment, like a bag you might have, you put things in it. Node is the most basic kind of 'bag'.

    In short, be aware of these distinctions in tutorials.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file