0 votes

I'm getting an error:

Script inherits from native type 'RigidBody2D', so it can't be instanced in object of type: 'CollisionPolygon2D'

The line in queston is:

func createSubRock(res, pos, x, y):
var _rock = load(res)
var rock = _rock.instance()     -------- HERE!!!
rock.set_pos(Vector2(pos.x + x, pos.y + y))
rock.score = 75
rock.add_to_group("rocks")
main.add_child(rock)

On one machine, it works but on another, it stops. What am I doing wrong here?

in Engine by (259 points)

Can you provide more information? Like:
Which Godot version are you using?
What are you trying to do?
Does the debugger/console say other things?
Im asking you because there can be more erros. Maybe Godot doesn't have admin permissions to write a file, or some methods changed in newer Godot versions

1 Answer

+1 vote

Oh dear, I've got my script attached to a CollisionPolygon2D node as well as RigidBody2d!

by (259 points)
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 Frequently asked questions and 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 [email protected] with your username.