Hello, i'm coding a basic game.
My problem is the following: on one hand, long ranged weapon works wells. I have followed this tutorial, and everything i get from here is on point. (link of said tutorial: http://kidscancode.org/blog/2018/04/godot3_tanks_part1/)
On the other, close combat weapon do not produce anything.
What i did:
if ($ArmeEquipee.cac):
var b = $ArmeEquipee.balle.instance()
self.add_child(b)
b.start(positionGlobale, dir)
else:
emit_signal('shoot', $ArmeEquipee.balle, positionGlobale, dir)
So, this is the code used when any character attack. The signal is linked to the main scene were the following piece of code generate my bullet!
func _gen_projo(bullet, _position, _direction):
var b = bullet.instance()
add_child(b)
b.start(_position, _direction)
To precise what is a weapon in my code: it is just a bunch of variable that will fixe the rate of fire, the scattering, the type of bullet used and if it's a CC weapon or a long range one. The code that "shoot" is written above, in the caracter.
Lastly, i tried to consider a CC weapon, as a long range one, and it works. (cac = true, for CC weapon, false for LR)
extends Node2D
var can_shoot = true
var balle
var gun_cooldown
var num
var dispersion
var cac
func _ready():
init()
$TpsRecharge.wait_time = gun_cooldown
pass # Replace with function body.
func init():
pass
func _on_TpsRecharge_timeout():
can_shoot=true
Conclusion / question:
Why the same code, with the same parameter, only work when a signal transmit the information between two scenes?