improve tiretrails
This commit is contained in:
parent
bf19c6989c
commit
57303f8d57
3 changed files with 9 additions and 3 deletions
|
@ -82,6 +82,7 @@ var burnout:float=0 #at 0 is off
|
||||||
@onready var sfx: Node = $SFX
|
@onready var sfx: Node = $SFX
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var playerid=0
|
var playerid=0
|
||||||
var finalTime=-1
|
var finalTime=-1
|
||||||
|
|
||||||
|
@ -113,11 +114,15 @@ func _physics_process(delta: float) -> void:
|
||||||
var collision = get_slide_collision(i)
|
var collision = get_slide_collision(i)
|
||||||
if $".".name==collision.get_collider().name: #collided with another car
|
if $".".name==collision.get_collider().name: #collided with another car
|
||||||
sfx.crashCarToCar(velocity.length())
|
sfx.crashCarToCar(velocity.length())
|
||||||
|
#collision.get_collider_velocity().length()
|
||||||
# velocity-=COLLISION_SLOWDOWN_CAR
|
# velocity-=COLLISION_SLOWDOWN_CAR
|
||||||
if ROAD_R_NAME==collision.get_collider().name or ROAD_L_NAME==collision.get_collider().name: #collided with road
|
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):
|
if (velocity.length()>MIN_CRASH_VELOCITY):
|
||||||
velocity/=COLLISION_SLOWDOWN_WALL
|
velocity/=COLLISION_SLOWDOWN_WALL
|
||||||
|
#sfx.crashBarrier(velocity.length())
|
||||||
sfx.crashBarrier(velocity.length())
|
sfx.crashBarrier(velocity.length())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if get_slide_collision_count()>0:
|
#if get_slide_collision_count()>0:
|
||||||
# velocity/=2
|
# velocity/=2
|
||||||
|
|
|
@ -20,6 +20,7 @@ func setPlayerinformation(playerid, playercolor):
|
||||||
cbcar.playerid=playerid
|
cbcar.playerid=playerid
|
||||||
carbody.modulate = playercolor
|
carbody.modulate = playercolor
|
||||||
|
|
||||||
|
|
||||||
func setCheckpoints(cps,rounds):
|
func setCheckpoints(cps,rounds):
|
||||||
cbcar.checkpoints=cps
|
cbcar.checkpoints=cps
|
||||||
cbcar.checkpointtimes.resize(cps.size()*rounds)
|
cbcar.checkpointtimes.resize(cps.size()*rounds)
|
||||||
|
|
|
@ -6,7 +6,7 @@ var isSliding=false
|
||||||
|
|
||||||
var currentTrail:Line2D
|
var currentTrail:Line2D
|
||||||
|
|
||||||
const STARTALPHA=0.8
|
const STARTALPHA=0.5
|
||||||
const MAXIMUM_POINTS=100 #maximum points per trail
|
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)
|
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()
|
c.queue_free()
|
||||||
|
|
||||||
func setSliding(psliding:bool):
|
func setSliding(psliding:bool):
|
||||||
if not isSliding and psliding: #just started sliding
|
if not isSliding and psliding: #just started sliding
|
||||||
#Create new Line
|
#Create new Line
|
||||||
currentTrail=Line2D.new()
|
currentTrail=Line2D.new()
|
||||||
add_child(currentTrail)
|
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(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)
|
curve.add_point(Vector2(1,0),-5,0,Curve.TANGENT_FREE,Curve.TANGENT_FREE)
|
||||||
currentTrail.width_curve=curve
|
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
|
currentTrail.z_index=8 #above road, behind car
|
||||||
|
|
||||||
isSliding=psliding
|
isSliding=psliding
|
||||||
|
|
Loading…
Reference in a new issue