0 votes

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.

Godot version 3.3.3
in Engine by (29 points)

1 Answer

0 votes

I guess nobody understands the question :)

Why can't You just extend CollisionObject2D ? Like using "extends" in script, it works.

by (5,092 points)

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.

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.