0 votes

This line in the tutorial for making a new 2D game on your Godot Documentation webpage is not working:
var velocity = Vector2(randrange(150.0, 250.0), 0.0)
mob.linear
velocity = velocity.rotated(direction) *

I'm not sure how to fix it. Any help would be appreciated.

Godot version v3.5.1 stable official
in Engine by (17 points)

1 Answer

0 votes
Best answer

I think the problem is with your Mob scene. Its root node should be of type Rigidbody2D but, according to the error, it's a Node2D.

If that's the case, you can right-click the root node in the Mob scene and use Change Type to set it to Rigidbody2D. Also, if the node type was wrong, you'll likely need to change the top line of the Mob script from:

extends Node2D

to...

extends RigidBody2D
by (19,302 points)
selected by

Thank you. You saved me a lot of headache.

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.