I am making a 3D game with a custom player controller. For now, it has always worked. Now, for some reason, the player flickers a bit up and down, like shown here, because instead of a CollisionShape
with a BoxShape or generated ConvexPolygonShape
being used, I used "Create Trimesh Static Body" on my collision mesh I imported from blender to create a ConcavePolygonShape
Video that shows the player flickering up and down (I couldn't get it to be embedded for some reason)
The custom player controller is pretty big, so I'm only going to show the important part (I left out the part that assigns the velocity and does other stuff not related to physics):
func _physics_process(delta):
# do physics
vertical_velocity -= gravity * delta
horizontal_velocity *= horizontal_drag
# ...
var to_move: Vector3 = Vector3(horizontal_velocity.x, vertical_velocity, horizontal_velocity.y) + anim_velocity * delta
var complete_velocity = move_and_slide(to_move, Vector3.UP)
horizontal_velocity.x = complete_velocity.x
horizontal_velocity.y = complete_velocity.z
vertical_velocity = complete_velocity.y
for i in range(get_slide_count()):
on_collision(get_slide_collision(i))
emit_signal("collide", get_slide_collision(i))
I have no idea why it worked with BoxShapes but not with a generated ConcavePolygonShape