i am new in this. i cant do my signals wor and i dont know why. i have read a lot of sites but i dont find the way to make my signals work.
i am tryigin to use they for knowing the localitation about where start (i am trying to sstar my lerning with a 2d rpg then character should be able to have several localitations available).
the thing is that i am trying to use first the signals for changing in code the start game localitation of the game even when i can do it in editor, i want to make it by signals because it will make me understand better how it works.
i also have test that i can change localitation of my game in code but no if i put the code inside the signal thing, i dont want the localitation of the room be always that, just the first time, the others times localitation must be in the door.
this is the code of my character:
signal personajecoll()
func _ready():
set_contact_monitor (true)
set_max_contacts_reported(15)
get_node("/root/Node2D/Nodedatos1").connect("posStart", self, "has_signal")
if has_signal ("PosStart") :
position.x = 320
position.y = 100
func _process(delta):
if has_signal("body_entered") :
emit_signal("personajecoll")
func _unhandled_key_input(event):
if event is InputEventKey :
if event.pressed and event.scancode == KEY_RIGHT :
linear_velocity.x = 20
linear_velocity.y = 0
angular_velocity = 0
if event is InputEventKey :
if event.pressed and event.scancode == KEY_LEFT :
linear_velocity.x = -20
linear_velocity.y = 0
angular_velocity = 0
if event is InputEventKey :
if event.pressed and event.scancode == KEY_DOWN :
linear_velocity.y = 20
linear_velocity.x = 0
angular_velocity = 0
if event is InputEventKey :
if event.pressed and event.scancode == KEY_UP :
linear_velocity.y = -20
linear_velocity.x = 0
angular_velocity = 0
if event.pressed == false :
linear_velocity.x = 0
linear_velocity.y = 0
_
and this the code from my autoload node that should control the localitation.
signal posStart()
signal pos_pasillolab_felixroom()
signal pos_felixroom()
func _ready():
if PlaceD == "0A" :
emit_signal ("posStart")
if PlaceD == "pasillolab_felixroom" :
emit_signal ("pos_pasillolab_felixroom")
if PlaceD == "felixroom" :
emit_signal ("pos_felixroom")
func _process(delta):
if has_signal("salidadehabitacionfelix") :
PlaceD = "pasillolab_felixroom"
if has_signal("entradadehabitacionfelix") :
PlaceD = "felixroom_" ~~~
pd dont read # things,, , commentary are from godot not from me , i am not erasing some for lazyness.
pd2: i have tabs inside the code but coping and pasting it have erased they in the web version.