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.
Challenge Solution CheckMoKTHey Nathan/Jad, I wanted to run my challenge solutions by you and see if you had any suggestions or efficiencies you would recommend?
For the first one I had no issues:
```gdscript
## game.gd
@onready var _timer: Timer = %Timer
func _ready() -> void:
_count_down.counting_finished.connect(
func() -> void:
_runner.set_physics_process(true)
_timer.start()
_timer.timeout.connect(
func() -> void:
_bouncer.set_physics_process(true)
)
)
_count_down.start_counting()
```
For the second, I thought about using lerp() and range(), I was trying to find a step function where I could state a min & max value, and an increment, but after reading the help docs I realized that's not what those are used for, I don't think that exists in gdscript?
I also thought about using a timer that limits the bouncers speed for a duration then ups it, but that would cause to quick a jump in speed.
In the end I used an if loop to increment:
```gdscript
## bouncer.gd
@export var max_speed_limit := 600.0
@export var max_speed := 0.0
@export var speed_increment := 600.0
func _physics_process(delta: float) -> void:
#...
+if max_speed < max_speed_limit:
max_speed += speed_increment * delta
+if max_speed > max_speed_limit:
max_speed = max_speed_limit
var speed := max_speed if distance > 100 else max_speed * distance / 100
#var speed := max_speed if distance > 100 else max_speed * distance / 100
var desired_velocity := direction * speed
```80Nov. 09, 2024
Test question where the correct answer is "Game/Player"ram876In the test question where the correct answer is "Game/Player", we don't actually have a Player node. I was confused for a second when I didn't see this node.10Nov. 06, 2024
Store reference to playerBrain Siege GameworksDoing this lesson, I used a different method of getting the players position. Namely making the function to get the player position get the player node instead and then storing the value of the get_player() function in a global variable in the _ready() function. Then used this reference var for the target position for the Bouncer.
I'm sure it's better to do it this way, considering you eliminate having to get a node twice every frame update.30Oct. 30, 2024
Another cool challenge/feature to addiguessfiveAfter just making it to the finish line and beating the AI, the game does not stop to play the confetti. The AI is not stopping and collides with player causing the game to reset before celebrating the player's win.
A challenge could be making the AI stop when the player enters the finish line.
If you would like to add this feature then wait to look at my approach below.
...
...
```gdscript
# Add in main game script
_finish_line.body_entered.connect(func(body: Node):
if body is Runner:
bouncer.set_physics_process(false)
bouncer.set_animation_to_idle()
)
# Add in `Bouncer` script
func set_animation_to_idle():
_runner_visual.animation_name = RunnerVisual.Animations.IDLE
_dust.emitting = false
```10Oct. 29, 2024
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.