How to make a script that extends an abstract node type

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By drumstickz64

I want to make a node that inherits from CollisionObject2D but I can’t attach this node anything because I can’t make a CollisionObject2D.

I thought about adding it to an Area2D, since it’s a super type of CollisionObject2D. But I don’t want to do that because it has functionality that i don’t want.

:bust_in_silhouette: Reply From: Inces

I guess nobody understands the question :slight_smile:

Why can’t You just extend CollisionObject2D ? Like using “extends” in script, it works.

I guess I didn’t explain the problem properly. I can make a script that extends a CollisionObject2D. I just can’t attach that script to a new node. I have to attach it a built in type that already extends CollisionObject2D. Like Area2D or KinematicBody2D. But i don’t want to attach my script to those nodes, I want to use it to make a new custom node (using the class_name keyword), but I can’t do that because because to make a new custom node I would first need to make a CollisionObject2D and attach my script to it, and I can’t do that because I can’t create a CollisionObject2D node, since it’s an abstract node.

drumstickz64 | 2021-10-24 14:34

I see. You want to save it as a scene. Take your extended script and use “class_name” to give it life as e new custom node. After this You will be able to choose it when attaching nodes to scene tree in editor.

Inces | 2021-10-24 15:22