Godot 3 - Nonexistent function 'move' in base 'KinematicBody2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By 99
:warning: Old Version Published before Godot 3 was released.

I get the error, Nonexistent function ‘move’ in base 'KinematicBody2D, when I run this script in Godot 3.0:

var vel = 0
func _process(delta):
    	if Input.is_action_pressed("acc") and vel < 5:
    		vel += 0.1
    	if Input.is_action_pressed("dec") and vel > -1:
    		vel -= 0.2
    	if Input.is_action_pressed("rmb"):
    		look_at(get_global_mouse_position())
    	move(Vector2(sin(rotation), cos(rotation)) * vel)

This works fine in Godot 2 (except ‘rotation’ is ‘get_rot()’). So, I thought the move function was changed, but everything I’m reading says it hasn’t… so, can someone explain what I’m doing wrong?

:bust_in_silhouette: Reply From: kidscancode

That’s because move() does not exist in 3.0.

Make sure you’re looking at the 3.0 docs:
http://docs.godotengine.org/en/latest/classes/class_kinematicbody2d.html

There are two movement-related functions in 3.0 for KinematicBody2D:

  • move_and_collide() - this one works like move() did in 2.1, except it returns a KinematicCollision2D object
  • move_and_slide() - this one automatically handles sliding along objects (good for handling ground collisions, for example)

Also, do that on _physics_process, not _process.

eons | 2018-01-21 19:40