Why when I run it to my app has been closed and write it - Nonexisten function apply_impulse in base Node2D. I see Godot's doc and I find it method and your parent is RigidBidy2D, but I do this code by the video and he use KinematicBody2D and it is alright
extends KinematicBody2D
var movespeed = 500
var bulletspeed = 2000
var bullet = preload("res://Bullet.tscn")
func _ready():
pass
func _physics_process(delta):
var motion = Vector2()
if Input.is_action_pressed('up'):
motion.y -= 1
if Input.is_action_pressed('down'):
motion.y += 1
if Input.is_action_pressed('right'):
motion.x += 1
if Input.is_action_pressed('left'):
motion.x -= 1
motion = motion.normalized()
motion = move_and_slide(motion * movespeed)
look_at(get_global_mouse_position())
if Input.is_action_just_pressed('LMB'):
fire()
func fire():
var bullet_instance = bullet.instance()
bullet_instance.position = get_global_position()
bullet_instance.rotation_degrees = rotation_degrees
bullet_instance.apply_impulse(Vector2(), Vector2(bulletspeed, 0).rotated(rotation))
get_tree().get_root().call_deferred("add_child", bullet_instance)