i tried everything i know and it still dosent work
code:
extends CharacterBody2D
var d = 0
const SPEED = 300.0
const JUMP_VELOCITY = -400.0 @onready var animatedS = $AnimatedSprite2D
Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting(“physics/2d/default_gravity”)
func flip(d):
var flip_test = true
if d == -1 :
flip_test = true
else:
flip_test = false
return flip_test
func animation(d):
var t = flip(d)
animatedS.set_flip_h(t)
if not is_on_floor():
animatedS.play("jump")
var f = animatedS.get_frame()
if f == 7 :
animatedS.pause()
elif d != 0:
animatedS.play("walk")
elif d == 0 :
animatedS.play("idle")
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y += gravity * delta
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction = Input.get_axis("ui_left", "ui_right")
d = direction
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
animation(d)
move_and_slide()
extends CharacterBody2D
var d = 0
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
@onready var animatedS = $AnimatedSprite2D
#Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
func flip(d):
var flip_test = true
if d == -1 :
flip_test = true
else:
flip_test = false
return flip_test
func animation(d):
var t = flip(d)
animatedS.set_flip_h(t)
if not is_on_floor():
animatedS.play("jump")
var f = animatedS.get_frame()
if f == 7 :
animatedS.pause()
elif d != 0:
animatedS.play("walk")
elif d == 0 :
animatedS.play("idle")
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y += gravity * delta
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction = Input.get_axis("ui_left", "ui_right")
d = direction
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
animation(d)
move_and_slide()
Also, there is a place which says type or paste code here. Just delete that and put your code between the three dots that appear above and below it. Make sure that the first 3 are on a line above the code and the second three are on the line below. Those lines must not have any letters on them. You seem to have only used one for in place of the three that appear. There is a button with the </> symbol on the top bar, or if your on a mobile, the setting looking thing on top of the text box.