Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends CharacterBody2D
- @export var SPEED = 300
- var ammo = 0
- func _physics_process(_delta):
- aiming()
- shooting()
- var direction = Input.get_vector("left","right","up","down")
- velocity = direction * SPEED
- move_and_slide()
- func aiming():
- var aim
- aim = get_global_mouse_position()
- look_at(aim)
- func shoot():
- const BULLET = preload("res://scene/bullets.tscn")
- var new_bullets = BULLET.instantiate()
- #spawn bullets at point
- new_bullets.global_position = %bullet_spawn.global_position
- #rotation of the bullet
- new_bullets.global_rotation = %bullet_spawn.global_rotation
- %bullet_spawn.add_child(new_bullets)
- func shooting():
- if Input.is_action_just_pressed("shoot"):
- shoot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement