30 lines
867 B
GDScript
30 lines
867 B
GDScript
extends Node2D
|
|
@onready var cbcar: CharacterBody2D = $CharacterBody_Car
|
|
@onready var carbody: Sprite2D = $CharacterBody_Car/sprite_body
|
|
|
|
|
|
func getSpeed() -> float:
|
|
return cbcar.velocity.length()
|
|
|
|
func getPosition():
|
|
return cbcar.position
|
|
|
|
func setPosition(p:Vector2):
|
|
cbcar.position=p
|
|
|
|
func setPlayerinformation(playerid, playercolor):
|
|
cbcar.playerid=playerid
|
|
carbody.modulate = playercolor
|
|
|
|
func setCheckpoints(cps):
|
|
cbcar.checkpoints=cps
|
|
cbcar.checkpointtimes.resize(cps.size())
|
|
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))
|