Invalid set index 'Linear_velocity' (on base: 'RigidBody2D (Mob.gd)') with value of type 'Vector2'.

Godot Version

3.5 Stable

Question

New to Godot and working on a beginner GDQuest 2D game tutorial. I’ve checked similar topics for ways to troubleshoot, but the solutions given to others aren’t working.

Code for my Main scene is as follows

extends Node

export (PackedScene) var mob_scene


func _on_MobTimer_timeout():
	var mob_spawn_location = $MobPath/MobSpawnLocation
	mob_spawn_location.unit_offset = randf()
	
	var mob = mob_scene.instance()
	add_child(mob)
	
	mob.position = mob_spawn_location.position
	
	var direction = mob_spawn_location.rotation + PI / 2
	direction += rand_range(-PI / 4, PI / 4)
	mob.rotation = direction
	
	var velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0)
	mob.Linear_velocity = velocity.rotated(direction)

My Mob.tscn code looks like this.

extends RigidBody2D

export var min_speed = 150.0
export var max_speed = 250.0

func _ready():
$AnimatedSprite.playing = true
var mob_types = $AnimatedSprite.frames.get_animation_names()
$AnimatedSprite.animation = mob_types[randi() % mob_types.size()]

func _on_VisibilityNotifier2D_screen_exited():
queue_free()

Past help topics offered the solution of double checking the type of node assigned to the mob, but mine is already assigned as a RigidBody2D node.

Any help would be appreciated :slight_smile:

It wants lower case mod.linear_velocity

1 Like