I've got a Kinematic character with a Capsule CollisionShape2d. When the lower curve of the capsule hits a platform, it launches the character in the air like they'd jumped. How do I prevent this?
Character Node structure:
KinematicBody2D
--CollisionsShape2D
--AnimatedSprite
Code:
func get_input():
velocity.x = 0
if Input.is_action_pressed("ui_right"):
TurnRight(true)
velocity.x += speed
if Input.is_action_pressed("ui_left"):
TurnRight(false)
velocity.x -= speed
func _physics_process(delta):
get_input()
var collision = move_and_collide((velocity +fanVelocity)* delta)
if (collision)&&(collision.collider.name.substr(0,10)=="CloudSmall"):
collision.collider.FadeOut()
if velocity.y < maxYvel:
velocity.y += gravity * delta
else: velocity.y = maxYvel
velocity = move_and_slide(velocity, Vector2.UP)
fanVelocity=Vector2(0,0)
Any ideas? I can't add physics materials to the KinematicBody2d, or a weight to affect gravity. I modified the code from a tutorial; it uses move_and_collide and later move_and_slide - is that a problem? When I remove move and collide, it still occurs. Removing move and slide, and the character gets stuck as it moves along the platform.
Thanks for any suggestions!