teststrecke-game/scripts/car_node.gd

27 lines
764 B
GDScript3
Raw Normal View History

2024-11-03 18:16:30 +00:00
extends Node2D
2024-11-04 20:56:07 +00:00
@onready var cbcar: CharacterBody2D = $CharacterBody_Car
@onready var carbody: Sprite2D = $CharacterBody_Car/sprite_body
2024-11-03 18:16:30 +00:00
func getSpeed() -> float:
2024-11-04 20:56:07 +00:00
return cbcar.velocity.length()
2024-11-03 18:16:30 +00:00
func getPosition():
2024-11-04 20:56:07 +00:00
return cbcar.position
2024-11-03 18:16:30 +00:00
func setPosition(p:Vector2):
2024-11-04 20:56:07 +00:00
cbcar.position=p
2024-11-03 18:16:30 +00:00
func setPlayerinformation(playerid, playercolor):
2024-11-04 20:56:07 +00:00
cbcar.playerid=playerid
2024-11-03 18:16:30 +00:00
#TODO set playercolor
2024-11-04 20:56:07 +00:00
carbody.modulate = playercolor
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))