Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.
Utilizing Timer Nodefilthy-rookI've tied a timers wait time function to an exported variable and just use it to call the destroy function, I did this before looking at any of the hints.
Will this cause problems later on, or is this a valid way to handle increasing/decreasing the range?00Jan. 22, 2025
Why _physics_process in Area2D?PurpleSunriseHello,
I thought _physics_process() it's used only for bodies like CharacterBody, StaticBody etc, while we use _process() for areas as areas are not subjected to physics. Or are they? Like areas can't collide right? I thought they just detect other Areas or physic object.
Here's my code:
```gdscript
extends Area2D
@export var speed : float = 100.0
var max_range : float = 300.0
var distance_traveled : float = 0.0
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
var direction = transform.x.normalized()
var velocity = direction * speed * delta
position += velocity
distance_traveled += speed * delta
if distance_traveled >= max_range:
destroy()
func destroy()->void:
queue_free()
```
Thank you!70Jan. 21, 2025
Is it ok to calculate the bullet distance using position?Lucas Pscheidt```gdscript
func _ready() -> void:
initial_position = global_position
func _process(delta: float) -> void:
if max_range < global_position.distance_to(initial_position):
_destroy()
```10Jan. 02, 2025
Lesson Q&A
Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.