• Godot Help
  • why a function dont run in my if statement, if it runs in other places.

code here

	if ink == 0 :
		# get_node("/root/Node2D/Nodedatos1").connect("posStart", self, "iniciop")
		PlaceD = get_node("/root/GlobalNode").get("PlaceD")
		if PlaceD == 1:
			ink =1
			iniciop()


func iniciop() :
	position.x = 320
	position.y = 50

i cant made the function iniciop() run in that place, i at start tought that was a problem in node connection but i have print(ink) and got 1 and PlaceD too then the requisites are afford. iniciop() just dont run, but it run well if i put it in ready or in procces at start(in this case i am get stuck but i only wanted to try if it ran in others places). i used the same code in the other cases. same line.

i can be a noob but i can affirm this situation just dont have sense.

Probably because the if condition for some reason doesn't return true when you expect it to so it gets passed over.

i put print in the iniciop function and it give me the string in console but there was no change of position in game.
how is possible that it run in console but not in game? how is possible that it run in game properly (the function, not what i want to do with it)if i put in another place but not there.

    mtcat i put print in the iniciop function and it give me the string in console but there was no change of position in game.

    What node type is this script attached to? You should probably share the whole script in here. It might be that you should use a function such as move_and_slide perhaps to move it, depending on the node type.

      Megalomaniak
      the main node is a rigidbody2d and the other node is a node(that is the name) and the script of node was put in autoload.
      i have the feeling that i have here the same problem than with signals, is like it dont detect other nodes in game.
      there is some option i should had to change for nodes being able to communicate between they?
      it is weird that they made it in console but not in game.
      i am using godot 3.5.1 and gles2.

      Megalomaniak. But it is possible to move they with position i have tried, it just dont run inside my if statement.

      I want to give it a start position (with alternatives position depending from what scene you came from) and applying force is not worth there because i dont want to see it move, just starting from different positions.

      I move my character with velocity but i dont want it to move in this function( movement is running well atleast in this scene), just start from differents positions.

        mtcat I want to give it a start position (with alternatives position depending from what scene you came from) and applying force is not worth there because i dont want to see it move, just starting from different positions.

        in that case handling it in ready() should be fine.

          Megalomaniak. Well i changed the code to ready ( ) an it runned well. I think that this problem is fixed yet.