improve tiretrails

This commit is contained in:
interfisch 2024-11-11 19:09:24 +01:00
parent bf19c6989c
commit 57303f8d57
3 changed files with 9 additions and 3 deletions

View file

@ -82,6 +82,7 @@ var burnout:float=0 #at 0 is off
@onready var sfx: Node = $SFX
var playerid=0
var finalTime=-1
@ -113,11 +114,15 @@ func _physics_process(delta: float) -> void:
var collision = get_slide_collision(i)
if $".".name==collision.get_collider().name: #collided with another car
sfx.crashCarToCar(velocity.length())
#collision.get_collider_velocity().length()
# velocity-=COLLISION_SLOWDOWN_CAR
if ROAD_R_NAME==collision.get_collider().name or ROAD_L_NAME==collision.get_collider().name: #collided with road
if (velocity.length()>MIN_CRASH_VELOCITY):
velocity/=COLLISION_SLOWDOWN_WALL
#sfx.crashBarrier(velocity.length())
sfx.crashBarrier(velocity.length())
#if get_slide_collision_count()>0:
# velocity/=2

View file

@ -20,6 +20,7 @@ func setPlayerinformation(playerid, playercolor):
cbcar.playerid=playerid
carbody.modulate = playercolor
func setCheckpoints(cps,rounds):
cbcar.checkpoints=cps
cbcar.checkpointtimes.resize(cps.size()*rounds)

View file

@ -6,7 +6,7 @@ var isSliding=false
var currentTrail:Line2D
const STARTALPHA=0.8
const STARTALPHA=0.5
const MAXIMUM_POINTS=100 #maximum points per trail
const FADETIME=120 #in seconds. how long a trail should last (if alpha would start at 1.0)
@ -26,7 +26,7 @@ func _physics_process(delta: float) -> void:
c.queue_free()
func setSliding(psliding:bool):
if not isSliding and psliding: #just started sliding
if not isSliding and psliding: #just started sliding
#Create new Line
currentTrail=Line2D.new()
add_child(currentTrail)
@ -37,7 +37,7 @@ func setSliding(psliding:bool):
curve.add_point(Vector2(0.5,1),0,0,Curve.TANGENT_FREE,Curve.TANGENT_FREE)
curve.add_point(Vector2(1,0),-5,0,Curve.TANGENT_FREE,Curve.TANGENT_FREE)
currentTrail.width_curve=curve
currentTrail.set_as_top_level(true)
currentTrail.set_as_top_level(true) #position is global position
currentTrail.z_index=8 #above road, behind car
isSliding=psliding