Godot: KinematicBody2D move does not update Collision Transform (only first move in _fixed_process does valid testing)

Created on 16 Mar 2017  ·  3Comments  ·  Source: godotengine/godot

Operating system or device - Godot version:
Windows 10 x64 - Godot 2.1.2.stable.official

Issue description:
After moveing a KinematicBody2D with move(), the Collider transformations are not updated.
Every move will only test with the initial Collider position/transformation.

Steps to reproduce:

  • Setup a scene with 1 KinematicBody2D (A) and 1 StaticBody2D (B) with rectangular CollisionShape2D
  • A is placed left to B (can have some space < 100px) and A and B CollisionSHapes are 64px x 64px
  • add a script to A with code:
func _ready():
    set_fixed_process(true)

func _fixed_process(delta):
    move(Vector2(0, 100))
    move(Vector2(100, 0))
    set_fixed_process(false)

A only moves down, but not to the right.
Even though after moving down, A would fit under B.
It should be under B and should have moved in an L-shape (first down, then right).
Move does not update Colliders to new position, so while trying to move right, it seems to be blocked by B, as it would be, if we only moved right.

Workaround:
change _fixed_process to:

func _fixed_process(delta):
    move(Vector2(0, 100))
    var st = get_shape_transform(0) # get current shape transform, assuming we only have 1 shape
    st.o += get_travel() # add move translation to shape transform
    set_shape_transform(0, st) # update shape transform
    move(Vector2(100, 0))
        # you should reset the shape transform to its original state befor returing
    set_fixed_process(false)
archived

Most helpful comment

I think this is duplicate of #7951, but I would like to have @RandomShaper to confirm :smiley:

All 3 comments

I think this is duplicate of #7951, but I would like to have @RandomShaper to confirm :smiley:

Yes, it's the same issue.

I missed that one.
Thanks.

Was this page helpful?
0 / 5 - 0 ratings