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.
ChargeAndShoot challenge - Projectiles's angle mathsKorielGreetings! So I had a go to this lesson's last challenge, and I came up with a very simple solution for spawning x amount of projectiles in a circle:
```gdscript
for i in projectile_amount:
var spawn_angle_increment := (2 * PI) / projectile_amount
var new_projectile := ProjectileScene.instantiate()
mob.add_sibling(new_projectile)
new_projectile.global_transform = mob.global_transform
new_projectile.rotate_y(i * spawn_angle_increment)
```
Then I went to check on the provided solution in the solutions project and - to me, someone with no maths knowledge whatsoever - seemed like a strange and overcomplicated solution which seemed to produce similar results but with more code.
```gdscript
var angle_interval := arc_angle / projectile_count
var half_arc := arc_angle / 2.0
for i in range(projectile_count):
var projectile := projectile_scene.instantiate()
mob.add_sibling(projectile)
projectile.global_position = mob.global_position
projectile.global_basis = mob.global_basis
projectile.rotate_y(half_arc - i * angle_interval)
```
I just can't figure out the exact reason to this approach, and I'd like to learn the why, since I imagine it does have a benefit that I'm not seeing.
Thank you!10Nov. 20, 2024
Not collidingRudiHi hi. I added a HitBox onto the bee, and I am doing the collision count `mob.get_slide_collision_count()` after the `move_and_slide`, but when it intersects the player, the player does indeed take damage. My expectation is that the bee would stop at that point, but it continues through the player and ends at the distance it would have normally finished.
How can I ensure that the collision does indeed work? In an earlier session, we set the bee's collider base collider to no layers.
I did add the player-level mask on the base Character3D collision section and that does work.20Oct. 01, 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.