-
Notifications
You must be signed in to change notification settings - Fork 0
A mina pode causar dano no player #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
27dff96
60a04c7
9ffdf12
180cd99
6f12511
cfb633e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ class_name Bullet3 extends Area2D | |
|
|
||
| var lifetime_seconds: float = 3.0 | ||
| var insta_kill_amount: float = 99999.0 | ||
| var can_hit_player: bool = false | ||
|
|
||
|
|
||
| ## Inicializa o timer e configura a mina para começar ativa e monitorando colisões. | ||
|
|
@@ -20,10 +21,20 @@ func _ready() -> void: | |
| explosion_animation.hide() | ||
| if not vanish_timer.timeout.is_connected(_on_vanish_timer_timeout): | ||
| vanish_timer.timeout.connect(_on_vanish_timer_timeout) | ||
| await get_tree().create_timer(0.2).timeout | ||
| can_hit_player = true | ||
|
|
||
|
|
||
| ## Detecta colisão com um corpo e aplica dano. | ||
| func _on_body_entered(body: Node) -> void: | ||
| if body.has_method("is_player"): | ||
| if not can_hit_player: | ||
| return | ||
| var damage = body.acceleration / 30.0 | ||
| if damage <= 10.0: | ||
| damage = 10.0 | ||
| body.health -= damage | ||
| _explode() | ||
| if body.has_method("take_damage"): | ||
| body.take_damage(insta_kill_amount, 1.0) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @iBerserker89 pelo que eu entendi a mina continua dando insta kill nos asteroids, acho que o melhor é ter uma função para calcular o dano e essa função ser utilizada tanto para o player qt para o inimigo
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolvido |
||
| _explode() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iBerserker89 pq essa variavel é declarada como false para depois mudar para true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A variável vira true após o timer de 0.2s no _ready (logo após a mina ser instanciada), pra que o player não tome dano no momento em que instancia a mina no mapa.