#Godot Bug?

13 messages · Page 1 of 1 (latest)

stark shuttle
#

`Code -
extends CharacterBody2D

var playerx = 50
var playery = 50

func _on_player_my_position(posx, posy):
playerx = posx
playery = posy
print(playerx, playery)

func _physics_process(delta):
print("This is running first")
#position += (player - position)/50
var new_x = move_toward(position.x, playerx, 10* delta)
var new_y = move_toward(position.y, playery, 10* delta)
position = Vector2(new_x, new_y) `

var playerx = 50
var playery = 50
is bandage solution, it is to prevent the error "playerx or playery is nil"

Code work fine, until i add multiple enemies. Only Enemy work properly, rest goes to 50, 50 instead of player's position

cinder gale
stark shuttle
cinder gale
stark shuttle
#

in enemy script?

cinder gale
#

eg you got to have something like player.my_position.connect(enemy._on_player_my_position)

#

i don't see it

cinder gale
#

if you connected it through the editor, you need to do the same for all four enemies, it sounds like you only connected one enemy to the signal (so they don't get the player position updates and will keep going to 50,50)

#

yes, i see the enemy script, but not the signal connect call

stark shuttle
#

ahh

#

Thank you dude
Im so fucking dumb