Solved.
Using Godot 2.1.4
I tried to approximate your setup using the info given
+ adding this TileMap kbscene.zip linked in this Kinematic Character (2D) tutorial
The kbscene.zip has a TileMap scene + a scene with Tilesets with collision objects
is described in the "Using tilemaps" Godot Docs tutorial
I used two scenes.
- Player.tscn
- map.scn -- from the kbscene.zip file
(and used this as the main scene)
I named the root node in map.scn to "World" to match your code.
To get the TileMap node under that to work properly,
I had to
- Open tileset_edit.scn -- from kbscene.zip
- Didn't change anything here b/c each sprite node already has
a StaticBody2D with a CollisionPolygon2D
- Scene -> Convert To... -> TileSet... -> saved under res://mytiles.res
- Clicked the map.scn's TileMap node under World
- Added "res://mytiles.res" -> TileMap's "Tile Set" in the Inspector
- I clicked TileMap node -> clicked Node panel -> Groups -> "Tileset" -> Add
( this makes any collision with anything drawn using this TileMap
return true for your code if( collider.is_in_group("Tileset") ):
)
I then drew a vertical wall + added a floor
Added an instance of Player.tscn under World
So the map.scn looks like this :
link to main map.scn picture

This is how I set up the Player.tscn scene :
link to Player.tscn node tree picture

NODE TREE
-- a KinematicBody2D named "Player" (as the root)
-- -- a CollisionShape2D with a simple box shape
-- -- -- a Sprite named "PlayerSprite"
So onto the code.
here was the first clue as to what was going on :
link

Kept getting an error reading :
"Condition ' !colliding ' is true. returned: 0"
Changed the code a bit to debug :
Link

bug identified : move(motion) -> is bringing Player out of a collision
Following picture is identical to the last,
but commented out the line #move(motion)
link

So.
Basically you need var collider = get_collider()
to be placed in your if (is_colliding()):
block
but before your move(motion)
call.
Fixed func _fixed_process(delta):
(rest of the code unchanged)
link to picture

func _fixed_process(delta):
velocity.y += delta * GRAVITY
if(jump_allowed_timer > 0):
jump_allowed_timer -= delta
var direction = 0
if (Input.is_action_pressed("ui_left")):
direction = -1
sprite.set_flip_h(true)
elif (Input.is_action_pressed("ui_right")):
direction = 1
sprite.set_flip_h(false)
velocity.x = lerp(velocity.x, PlayerSpeed * direction, Smoothness)
var motion = velocity * delta
motion = move(motion)
if (is_colliding()):
var normal = get_collision_normal()
motion = normal.slide(motion)
velocity = normal.slide(velocity)
var collider = get_collider()
move(motion)
###if you need to debug collision groups
#
#if collider.is_in_group("Tileset") :
# print("collider in group 'Tileset'")
if ( Input.is_action_pressed("ui_jump") && is_jump_allowed() && collider.is_in_group("Tileset") ):
velocity.y -= JUMP_STRENGTH
jump_allowed_timer = JUMP_LIMIT
hint : you can copy paste code from this site into Godot
then ctrl+r to replace sets of 4 spaces (" ") with the tab character
(type a TAB in Godot -> copy paste a single tab character into the replace menu)