Advertisement
KennyAlbano69

ProjectTombStone

Apr 29th, 2024
962
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extends CharacterBody2D
  2.  
  3. const SPEED = 200.0
  4. const JUMP_VELOCITY = -400.0
  5. # Get the gravity from the project settings to be synced with RigidBody nodes.
  6. var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
  7. @onready var anim = get_node("AnimatedSprite2D")
  8. #@onready var ladderCheck = $LadderCheck
  9. func _physics_process(delta):
  10.     # Add the gravity.
  11.     velocity.y += gravity * delta
  12.        
  13.     #if is_on_ladder():
  14.         #print("on ladder")
  15.     # Handle jump.
  16.     if Input.is_action_just_pressed("ui_accept") and is_on_floor():
  17.         velocity.y = JUMP_VELOCITY
  18.  
  19. #func is_on_ladder():
  20.     #if not ladderCheck.is_colliding(): return false
  21.     #var collider = ladderCheck.get_collider()
  22.     #if not collider is Ladder: return false
  23.     #return true
  24.    
  25.     # Get the input direction and handle the movement/deceleration.
  26.     # As good practice, you should replace   UI actions with custom gameplay actions.
  27.     var direction = Input.get_axis("ui_left", "ui_right")
  28.     if direction:
  29.         velocity.x = direction * SPEED
  30.  
  31.     else:
  32.         velocity.x = move_toward(velocity.x, 0, SPEED)
  33.  
  34.     move_and_slide()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement