Guest User

player

a guest
Nov 2nd, 2023
568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. extends CharacterBody2D
  2.  
  3. @export var bullet_node: PackedScene
  4.  
  5. func _physics_process(_delta):
  6. velocity = Input.get_vector("ui_left","ui_right","ui_up","ui_down") * 250
  7. move_and_slide()
  8.  
  9.  
  10. func shoot():
  11. var bullet = bullet_node.instantiate()
  12.  
  13. bullet.position = global_position
  14. bullet.direction = (get_global_mouse_position() - global_position).normalized()
  15. get_tree().current_scene.call_deferred("add_child",bullet)
  16.  
  17. func _input(event):
  18. if event.is_action("shoot"):
  19. shoot()
  20.  
Advertisement
Add Comment
Please, Sign In to add comment