![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Halfpixel |
Hello, I’m new to programming and Godot.
I need help with my bullet, if it hits the player it disappears “queue_free()”, acts normal.
However, if my player moves the missed bullet gets stuck and it jitters.
Code:
extends Area2D
var speed = 300
onready var player = get_node(“/root/Node/Player”)
var target = Vector2()
var velocity = Vector2()
func _ready():
look_at(position)
target = player.global_position
func _physics_process(delta):
velocity = position.direction_to(target) * speed
velocity = velocity.rotated(rotation)
translate(velocity * delta)
func _on_VisibilityNotifier2D_screen_exited():
queue_free()
func _on_Redlaser_body_entered(body):
queue_free()
maybe try
func physicsprocess(delta):
if target != null:
velocity = position.direction_to(target) * speed
func onVisibilityNotifier2Dscreenexited():
target = null
queue_free
ramazan | 2022-02-10 13:11