extends Node2D @onready var cbcar: CharacterBody2D = $CharacterBody_Car @onready var carbody: Sprite2D = $CharacterBody_Car/sprite_body var reference_gamestateplayer func getSpeed() -> float: return cbcar.velocity.length() func getPosition(): return cbcar.position func getPositionLookahead(t:float): #return position of car in t seconds return getPosition()+cbcar.velocity*t func setPosition(p:Vector2): cbcar.position=p func setPlayerinformation(playerid, playercolor,preference_gamestateplayer): cbcar.playerid=playerid carbody.modulate = playercolor reference_gamestateplayer=preference_gamestateplayer func setCheckpoints(cps,rounds): cbcar.checkpoints=cps cbcar.checkpointtimes.resize(cps.size()*rounds) cbcar.checkpointtimes.fill(0.0) func move_and_slide(): cbcar.move_and_slide() func printDebug(): for i in cbcar.get_slide_collision_count(): var collision = cbcar.get_slide_collision(i) print(""+str(cbcar.playerid)+" Collided with: "+ str( collision.get_collider().name)+" pid="+str(collision.get_collider().playerid)+" pos="+str(collision.get_collider().position)) func setRunning(r:bool): cbcar.running=r func getCharacterBody(): return cbcar func hasFinished(): return cbcar.finalTime!=-1