Looks like you're not logged in

Login or Register to continue

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.

  • Code so far for "Dealing Damage with Projectiles" created in Godot 4.0 Betacacapon**\*Not a question.However, there are some things we do not understand.** We share the code we created with Godot4.0-bata for learning purposes. I am not confident of the code due to the lack of testing in this chapter. I am sure that running the scene does not generate any errors. Bullet.tscn ![2-09-30 11.42.53.png](https://d1tq3fcx54x7ou.cloudfront.net/uploads/store/tenant_128/image/2376/image/large-c689b0d863056bd160c054f5b9a95b19.png) Bullet.gd ```gdscript class_name Bullet extends Node2D @export var speed := 500.0 # onready var _tween := $Tween # tween node is obsolete @onready var _tween = get_tree().create_tween() @onready var _anim_player := $AnimationPlayer func _init(): # set_as_toplevel(true) # not found. pass func _fly_to(target_global_position: Vector2) -> void: var distance := global_position.distance_to(target_global_position) var duration := distance / speed # 3.x is _tween.interpolate_property(self,"global_position", global_position, target_global_position, duration) _tween.tween_property(self, "global_position", target_global_position,duration) _tween.play() # 3.x is _tween.start() look_at(target_global_position) await _tween.finished _anim_player.play("Explode") ``` ## The part that caught my attention - Where is set_as_toplevel()? (It seems to be in Node,Node3D but I can't find it in Node2D.) - Tween is handled much differently. a: Function arguments are different. b: Tween function names are also different. ## Other Comments - Maybe I'm getting used to writing. - Sprite's Region automatically set the coordinates when clicked. You didn't have to set the values one by one... - Tween relationships were referenced [here](https://zenn.dev/slm/articles/39d3bd54f98cb9). (This is a blog in Japanese.) 2 1 Sep. 30, 2022
  • bullet maybe miss?xccdsfrom the bullet code, it will be shoot when weapon detect the enemy. the bullet need some time to hit the target position. if enemy move fast, there are chance that bullet hit nothing but still has a explosion , am I right? 1 0 Jul. 10, 2024
  • SmallExplosion startet to emmit immediatelyOdontyHello all I had to add another line of code to my bullet script ```gdscript func _ready() -> void: $SmallExplosion.emitting = false ``` This because the particles started immediately to emitting, although I deactivated the "emitting on" property in the inspector. I tested it only on Godot 4 as I do this course on Godot 4 to strengthen my skill to understand code. Could anybody investigate the same behavior, or is something wrong with my setting? After adding this line of code, it emits as expected when the bullet is on the target and disappears afterward. 2 0 May. 13, 2024
Site is in BETA!found a bug?