My KinematicBody2D's movement stopped working since Godot 3.1 alpha 3

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By alforiumstudios

I’m having issues when loading my project in the latest engine alpha. Player movement no longer works in Godot 3.1 alpha 3 and alpha 4, but it worked fine up until alpha 2.

The player is a KinematicBody2D and I’m using move_and_collide(). This is the relevant part of the code, I think:

	if not is_moving and direction != Vector2():
		target_direction = direction.normalized()
		if grid.is_cell_vacant(get_position(), direction):
			target_pos = grid.update_child_pos(get_position(), direction, type)
			is_moving = true
	elif is_moving:
		#print("current room: " + str(get_room()))
		if global.on_episode == false and global.HP > 0: get_worldmap_coordinates()
		speed = MAX_SPEED
		velocity = speed * target_direction * delta

		var pos = get_position()
		var distance_to_target = pos.distance_to(target_pos)
		var move_distance = velocity.length()

		if move_distance > distance_to_target:
			velocity = target_direction * distance_to_target
			is_moving = false


“grid” is a TileMap and the parent of the player.

My player script is a bit complex (and messy at parts, since I’m an amateur) and it depends on other scripts, so the problem might lay elsewhere. This is the complete script, for reference:
The project is open-source, so you can even download the entire game and try it out yourself. The player gets stuck and doesn’t move.

I’ve been looking at the engine’s change logs, pull requests, etc. but I can’t figure out what’s changed to suddenly break this. Has there been any important changes in stuff like framerate calculation, collision, etc.? Or perhaps breaking changes in how TileMaps are handled?

I’d really appreciate any help!

You should probably report this as a bug too. Such a breaking change should at least be in a change log, if not corrected.

Ruckus T-Boom | 2019-01-03 16:33

:bust_in_silhouette: Reply From: jsilvano

Did you add a CollisionShape2D as a child to the KinematicBody2D node?

I’ve only started using Godot today and couldn’t get my sprite moving. I figured out that I need to add a CollisionShape2D, but nobody mentioned this in YouTube tutorials so I assume it’s a new thing.

Thank you thank you thank you! That was exactly it! I use a tilemap grid for movement, so none of my kinematicbody2d nodes had collision shapes assigned to them. Thanks so much :slight_smile:

alforiumstudios | 2019-01-02 21:37

Nice one. I bumped into this thread while I was searching for the solution, it’s nice to know now I’ve helped you solve it :slight_smile:

jsilvano | 2019-01-07 19:27