I'm trying to create a score to make a pong game but the player's score starts at 2 and the enemy's at 1 when I put 0 in the variables
extends Node
var playerscore = 0
var oponentscore = 0
func onmetaderrotabodyentered(body):
$pelota.position = Vector2(640, 360)
$oponent.position = Vector2(1243, 364)
$jugador.position = Vector2(44, 364)
oponentscore += 1
gettree().callgroup('pelota' , 'stoppelota')
$Timer.start()
func onmetavictoriabodyentered(body):
$pelota.position = Vector2(640, 360)
$jugador.position = Vector2(44, 364)
$oponent.position = Vector2(1243, 364)
playerscore += 1
gettree().callgroup('pelota' , 'stoppelota')
$Timer.start()
func process(delta):
$playerscore.text = str(playerscore)
$oponentscore.text = str(oponentscore)
$Timer.text = str(int($Timer.timeleft))
func onTimertimeout():
gettree().callgroup('pelota' , 'restartpelota')