So i am new to this gdscript, and struggled to code a jump, this is my attempt
extends KinematicBody2D
var velocity := Vector2.ZERO
export var speed := 400.0
export var gravity := 1.0
export var jumppower := 40.0
func _ready():
pass # Replace with function body.
func physicsprocess(delta):
velocity.x=Input.getactionstrength("Right")-Input.getactionstrength("Left")
velocity.y=gravity
if(Input.isactionjustpressed("Jump")):
velocity.y-=jumppower
if(velocity.y<1.0):
velocity.y+=gravity
velocity= velocity*speed
moveand_slide(velocity)
I want an ordinary jump, but instead the script makes it teleport upwards then fall ordinarily. Are there any tips for fixing this issue? Thanks in advance, and sorry if my code is quite a mess.