Bullet Code does not work as planned :(

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By PlamAtom

Hey Guys,

I can’t get my bullet to come out of the nose of the plane. I don’t understand why I can’t replace the Global Position or why the global position doesn’t work… Thx for any help!

My Code

extends KinematicBody2D

onready var cursor = $Tracker
onready var ship = $Texture
onready var trail = $Engine

func _ready():
	Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
	pass

const pull = 40
const speedmult = 4.5
const afterburn = 120
const upvector = Vector2(0,-1)

var player_movement = Vector2(pull,0)
var bullet_speed = 5
var bullet = preload("res://Bullet.tscn")

func _process(delta):
	
	_arrow()
	
	player_movement.y = 0
	ship.rotation = 0
	trail.rotation = PI/2
	trail.position.y = ship.position.y
	
	_checkkeyinput()
	move_and_slide(player_movement, upvector)

func _checkkeyinput():
	if Input.is_action_pressed("up"):
		player_movement.y = -20 * speedmult
		ship.rotation = 3600
		trail.rotation = PI/2 * 4.56
		trail.position.y = ship.position.y +4

	if Input.is_action_pressed("down"):
		player_movement.y = 20 * speedmult
		ship.rotation = -3600
		trail.rotation = PI/2 * 5.5
		trail.position.y = ship.position.y -4
		
	if Input.is_action_just_pressed("shift"):
	 _afterburn()
	
	if Input.is_action_just_released("shift"):
			player_movement.x = pull
			
	if Input.is_action_pressed("strg"): #Debug
			player_movement.x = -10
			
	if Input.is_action_just_pressed("right_mouse"):
		_fire()

func _arrow(): 
	cursor.global_position = get_global_mouse_position()	
	
func _afterburn():
		player_movement.x = afterburn
		
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(bullet_speed,0))
	get_tree().get_root().call_deferred("add_child", bullet_instance)
	
:bust_in_silhouette: Reply From: Inces

But You are not really using global_position. First try :
bullet_instance.global_position = get_global_position()