Add tire smoke
parent
82d7971153
commit
6d663bdfa0
|
@ -8,6 +8,16 @@
|
||||||
|
|
||||||
config_version=4
|
config_version=4
|
||||||
|
|
||||||
|
_global_script_classes=[ {
|
||||||
|
"base": "Particles",
|
||||||
|
"class": "TireSmoke",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://vehicles/tire_smoke.gd"
|
||||||
|
} ]
|
||||||
|
_global_script_class_icons={
|
||||||
|
"TireSmoke": ""
|
||||||
|
}
|
||||||
|
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="bugged-racing"
|
config/name="bugged-racing"
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
[gd_scene load_steps=7 format=2]
|
[gd_scene load_steps=13 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://vehicles/buggy.gd" type="Script" id=1]
|
[ext_resource path="res://vehicles/buggy.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://assets/beetlecar.glb" type="PackedScene" id=2]
|
[ext_resource path="res://assets/beetlecar.glb" type="PackedScene" id=2]
|
||||||
|
[ext_resource path="res://vehicles/tire_smoke.tscn" type="PackedScene" id=3]
|
||||||
|
|
||||||
[sub_resource type="Curve" id=3]
|
[sub_resource type="Curve" id=3]
|
||||||
_data = [ Vector2( 0, 0 ), 0.0, 2.58337, 0, 1, Vector2( 0.221698, 0.572727 ), 2.58337, 0.0, 1, 0, Vector2( 0.830189, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ]
|
_data = [ Vector2( 0, 0 ), 0.0, 2.58337, 0, 1, Vector2( 0.221698, 0.572727 ), 2.58337, 0.0, 1, 0, Vector2( 0.830189, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ]
|
||||||
|
@ -16,6 +17,30 @@ extents = Vector3( 0.417676, 0.42291, 1.58775 )
|
||||||
mix_rate = 5500.0
|
mix_rate = 5500.0
|
||||||
buffer_length = 1.0
|
buffer_length = 1.0
|
||||||
|
|
||||||
|
[sub_resource type="Curve" id=9]
|
||||||
|
_data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0.493182 ), 0.0, 0.0, 0, 0 ]
|
||||||
|
|
||||||
|
[sub_resource type="CurveTexture" id=10]
|
||||||
|
curve = SubResource( 9 )
|
||||||
|
|
||||||
|
[sub_resource type="ParticlesMaterial" id=7]
|
||||||
|
direction = Vector3( 0, 0, -1 )
|
||||||
|
gravity = Vector3( 0, 0.2, 0 )
|
||||||
|
initial_velocity = 0.8
|
||||||
|
scale = 0.1
|
||||||
|
scale_random = 0.17
|
||||||
|
scale_curve = SubResource( 10 )
|
||||||
|
color = Color( 0.0705882, 0.0705882, 0.0705882, 0.435294 )
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=6]
|
||||||
|
flags_transparent = true
|
||||||
|
vertex_color_use_as_albedo = true
|
||||||
|
|
||||||
|
[sub_resource type="SphereMesh" id=8]
|
||||||
|
material = SubResource( 6 )
|
||||||
|
radial_segments = 4
|
||||||
|
rings = 3
|
||||||
|
|
||||||
[node name="beetlecar" instance=ExtResource( 2 )]
|
[node name="beetlecar" instance=ExtResource( 2 )]
|
||||||
mass = 140.0
|
mass = 140.0
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
@ -77,3 +102,22 @@ __meta__ = {
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.14201, 0.968668 )
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.14201, 0.968668 )
|
||||||
stream = SubResource( 2 )
|
stream = SubResource( 2 )
|
||||||
unit_db = 14.0
|
unit_db = 14.0
|
||||||
|
|
||||||
|
[node name="Smoke" type="Particles" parent="." index="9"]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.31514, 0.383062, -1.51247 )
|
||||||
|
amount = 12
|
||||||
|
local_coords = false
|
||||||
|
process_material = SubResource( 7 )
|
||||||
|
draw_pass_1 = SubResource( 8 )
|
||||||
|
|
||||||
|
[node name="rr_tire_smoke" parent="." index="10" instance=ExtResource( 3 )]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.621508, 0.0502438, -0.83483 )
|
||||||
|
|
||||||
|
[node name="rl_tire_smoke" parent="." index="11" instance=ExtResource( 3 )]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, -1.50996e-07, 0, 1.50996e-07, 1, 0.621506, 0.0502438, -0.83483 )
|
||||||
|
|
||||||
|
[node name="fr_tire_smoke" parent="." index="12" instance=ExtResource( 3 )]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.621508, 0.0502438, 1.19336 )
|
||||||
|
|
||||||
|
[node name="fl_tire_smoke" parent="." index="13" instance=ExtResource( 3 )]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, -1.50996e-07, 0, 1.50996e-07, 1, 0.621506, 0.0502438, 1.19336 )
|
||||||
|
|
|
@ -35,6 +35,10 @@ onready var frwheel: VehicleWheel = $front_right
|
||||||
onready var flwheel: VehicleWheel = $front_left
|
onready var flwheel: VehicleWheel = $front_left
|
||||||
onready var rrwheel: VehicleWheel = $rear_right
|
onready var rrwheel: VehicleWheel = $rear_right
|
||||||
onready var rlwheel: VehicleWheel = $rear_left
|
onready var rlwheel: VehicleWheel = $rear_left
|
||||||
|
onready var frsmoke: TireSmoke = $fr_tire_smoke
|
||||||
|
onready var flsmoke: TireSmoke = $fl_tire_smoke
|
||||||
|
onready var rrsmoke: TireSmoke = $rr_tire_smoke
|
||||||
|
onready var rlsmoke: TireSmoke = $rl_tire_smoke
|
||||||
|
|
||||||
onready var engine_sound_player: AudioStreamPlayer3D = $engine_sound_player
|
onready var engine_sound_player: AudioStreamPlayer3D = $engine_sound_player
|
||||||
onready var engine_sound_playback: AudioStreamPlayback = $engine_sound_player.get_stream_playback()
|
onready var engine_sound_playback: AudioStreamPlayback = $engine_sound_player.get_stream_playback()
|
||||||
|
@ -76,6 +80,10 @@ func _has_traction():
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
func _update_wheels_smoke():
|
||||||
|
for wheelnsmoke in [[frwheel, frsmoke], [flwheel, flsmoke], [rrwheel, rrsmoke], [rlwheel, rlsmoke]]:
|
||||||
|
wheelnsmoke[1].update(wheelnsmoke[0].get_skidinfo())
|
||||||
|
|
||||||
func _lerp_rpm(from, to, delta, factor):
|
func _lerp_rpm(from, to, delta, factor):
|
||||||
var new_val = lerp(from, to, factor)
|
var new_val = lerp(from, to, factor)
|
||||||
if abs(from - new_val) > MAX_RPM_LOSS_PS * delta:
|
if abs(from - new_val) > MAX_RPM_LOSS_PS * delta:
|
||||||
|
@ -84,6 +92,7 @@ func _lerp_rpm(from, to, delta, factor):
|
||||||
return new_val
|
return new_val
|
||||||
|
|
||||||
func _physics_process(delta: float):
|
func _physics_process(delta: float):
|
||||||
|
_update_wheels_smoke()
|
||||||
clutch_position = Input.get_action_strength("clutch")
|
clutch_position = Input.get_action_strength("clutch")
|
||||||
_handle_gear_switch(delta)
|
_handle_gear_switch(delta)
|
||||||
var throttle = Input.get_action_strength("throttle")
|
var throttle = Input.get_action_strength("throttle")
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
[gd_scene load_steps=7 format=2]
|
[gd_scene load_steps=13 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://assets/basic_buggy.glb" type="PackedScene" id=1]
|
[ext_resource path="res://assets/basic_buggy.glb" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://vehicles/tire_smoke.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://vehicles/buggy.gd" type="Script" id=3]
|
[ext_resource path="res://vehicles/buggy.gd" type="Script" id=3]
|
||||||
|
|
||||||
[sub_resource type="Curve" id=2]
|
[sub_resource type="Curve" id=2]
|
||||||
|
@ -15,6 +16,30 @@ extents = Vector3( 0.521885, 0.334919, 1.78849 )
|
||||||
[sub_resource type="AudioStreamGenerator" id=3]
|
[sub_resource type="AudioStreamGenerator" id=3]
|
||||||
mix_rate = 5500.0
|
mix_rate = 5500.0
|
||||||
|
|
||||||
|
[sub_resource type="Curve" id=8]
|
||||||
|
_data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0.205682 ), 0.0, 0.0, 0, 0 ]
|
||||||
|
|
||||||
|
[sub_resource type="CurveTexture" id=9]
|
||||||
|
curve = SubResource( 8 )
|
||||||
|
|
||||||
|
[sub_resource type="ParticlesMaterial" id=5]
|
||||||
|
direction = Vector3( 0, 0, -1 )
|
||||||
|
gravity = Vector3( 0, 0.2, 0 )
|
||||||
|
initial_velocity = 0.8
|
||||||
|
scale = 0.2
|
||||||
|
scale_random = 0.25
|
||||||
|
scale_curve = SubResource( 9 )
|
||||||
|
color = Color( 0.521569, 0.521569, 0.521569, 0.435294 )
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=10]
|
||||||
|
flags_transparent = true
|
||||||
|
vertex_color_use_as_albedo = true
|
||||||
|
|
||||||
|
[sub_resource type="SphereMesh" id=7]
|
||||||
|
material = SubResource( 10 )
|
||||||
|
radial_segments = 4
|
||||||
|
rings = 3
|
||||||
|
|
||||||
[node name="buggy" instance=ExtResource( 1 )]
|
[node name="buggy" instance=ExtResource( 1 )]
|
||||||
mass = 150.0
|
mass = 150.0
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
|
@ -80,3 +105,21 @@ __meta__ = {
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.14201, 0.968668 )
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.14201, 0.968668 )
|
||||||
stream = SubResource( 3 )
|
stream = SubResource( 3 )
|
||||||
unit_db = 14.0
|
unit_db = 14.0
|
||||||
|
|
||||||
|
[node name="Smoke" type="Particles" parent="." index="9"]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.855953, -1.87797 )
|
||||||
|
local_coords = false
|
||||||
|
process_material = SubResource( 5 )
|
||||||
|
draw_pass_1 = SubResource( 7 )
|
||||||
|
|
||||||
|
[node name="fl_tire_smoke" parent="." index="10" instance=ExtResource( 2 )]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.950754, -0.0380455, 1.41438 )
|
||||||
|
|
||||||
|
[node name="fr_tire_smoke" parent="." index="11" instance=ExtResource( 2 )]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, -1.50996e-07, 0, 1.50996e-07, 1, -0.950754, -0.038045, 1.41438 )
|
||||||
|
|
||||||
|
[node name="rl_tire_smoke" parent="." index="12" instance=ExtResource( 2 )]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.950753, -0.0380455, -1.41438 )
|
||||||
|
|
||||||
|
[node name="rr_tire_smoke" parent="." index="13" instance=ExtResource( 2 )]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, -1.50996e-07, 0, 1.50996e-07, 1, -0.950755, -0.038045, -1.41438 )
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
class_name TireSmoke
|
||||||
|
extends Particles
|
||||||
|
|
||||||
|
func update(skidinfo: float) -> void:
|
||||||
|
if skidinfo < 0.5:
|
||||||
|
emitting = true
|
||||||
|
else:
|
||||||
|
emitting = false
|
|
@ -0,0 +1,36 @@
|
||||||
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://vehicles/tire_smoke.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="Curve" id=1]
|
||||||
|
_data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0.0170454 ), 0.0, 0.0, 0, 0 ]
|
||||||
|
|
||||||
|
[sub_resource type="CurveTexture" id=2]
|
||||||
|
curve = SubResource( 1 )
|
||||||
|
|
||||||
|
[sub_resource type="ParticlesMaterial" id=3]
|
||||||
|
gravity = Vector3( 0, 0.1, 0 )
|
||||||
|
initial_velocity = 0.2
|
||||||
|
scale = 0.1
|
||||||
|
scale_random = 0.36
|
||||||
|
scale_curve = SubResource( 2 )
|
||||||
|
color = Color( 0.839216, 0.839216, 0.839216, 0.45098 )
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=4]
|
||||||
|
flags_transparent = true
|
||||||
|
vertex_color_use_as_albedo = true
|
||||||
|
|
||||||
|
[sub_resource type="SphereMesh" id=5]
|
||||||
|
material = SubResource( 4 )
|
||||||
|
radial_segments = 4
|
||||||
|
rings = 4
|
||||||
|
|
||||||
|
[node name="tire_smoke" type="Particles"]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.541801, 0 )
|
||||||
|
emitting = false
|
||||||
|
lifetime = 0.49
|
||||||
|
explosiveness = 0.54
|
||||||
|
local_coords = false
|
||||||
|
process_material = SubResource( 3 )
|
||||||
|
draw_pass_1 = SubResource( 5 )
|
||||||
|
script = ExtResource( 1 )
|
Loading…
Reference in New Issue