rotating steering wheel
This commit is contained in:
parent
febeb03ee9
commit
ab5d2441a2
7 changed files with 56 additions and 6 deletions
|
@ -1,10 +1,11 @@
|
|||
[gd_scene load_steps=50 format=3 uid="uid://0g7qqh7naniv"]
|
||||
[gd_scene load_steps=51 format=3 uid="uid://0g7qqh7naniv"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/car_node.gd" id="1_0tin3"]
|
||||
[ext_resource type="Script" path="res://scripts/car.gd" id="1_i5tet"]
|
||||
[ext_resource type="Texture2D" uid="uid://c5rlo1fhm3bl4" path="res://sprites/bobbycar_features.png" id="3_k2wmt"]
|
||||
[ext_resource type="Texture2D" uid="uid://dojj5iqges76q" path="res://sprites/bobbycar_body.png" id="4_2gwtk"]
|
||||
[ext_resource type="Script" path="res://scripts/tiretrails.gd" id="5_4geqi"]
|
||||
[ext_resource type="Texture2D" uid="uid://dkg8e3stos5rw" path="res://sprites/bobbycar_steeringwheel.png" id="5_swfp0"]
|
||||
[ext_resource type="Script" path="res://scripts/label_round.gd" id="5_vheit"]
|
||||
[ext_resource type="PackedScene" uid="uid://dilif5od0ipli" path="res://scenes/burnout.tscn" id="6_nxxrr"]
|
||||
[ext_resource type="PackedScene" uid="uid://dl7r8s5sxyvlw" path="res://scenes/enginesound.tscn" id="6_v21se"]
|
||||
|
@ -140,17 +141,25 @@ script = ExtResource("1_0tin3")
|
|||
motion_mode = 1
|
||||
script = ExtResource("1_i5tet")
|
||||
|
||||
[node name="sprite_body" type="Sprite2D" parent="CharacterBody_Car"]
|
||||
z_index = 10
|
||||
texture_filter = 1
|
||||
scale = Vector2(0.5, 0.5)
|
||||
texture = ExtResource("4_2gwtk")
|
||||
|
||||
[node name="sprite_features" type="Sprite2D" parent="CharacterBody_Car"]
|
||||
z_index = 10
|
||||
texture_filter = 1
|
||||
scale = Vector2(0.5, 0.5)
|
||||
texture = ExtResource("3_k2wmt")
|
||||
|
||||
[node name="sprite_body" type="Sprite2D" parent="CharacterBody_Car"]
|
||||
[node name="sprite_steeringwheel" type="Sprite2D" parent="CharacterBody_Car"]
|
||||
z_index = 10
|
||||
texture_filter = 1
|
||||
position = Vector2(3, 0)
|
||||
scale = Vector2(0.5, 0.5)
|
||||
texture = ExtResource("4_2gwtk")
|
||||
texture = ExtResource("5_swfp0")
|
||||
offset = Vector2(-6, 0)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody_Car"]
|
||||
rotation = -1.57079
|
||||
|
|
|
@ -36,6 +36,9 @@ var slip_speed = 150
|
|||
var traction_fast = 0.05 #traction when above slip_speed
|
||||
var traction_slow = 0.5
|
||||
|
||||
var max_steering_change = 2.5
|
||||
var turndirection_scale = 0.01
|
||||
|
||||
|
||||
#Automatic Steering settings
|
||||
|
||||
|
@ -203,16 +206,17 @@ func get_input(delta:float):
|
|||
|
||||
var distance_min= min(distance_fl,distance_fr)
|
||||
|
||||
var turndirection = 1 if distance_fl<distance_fr else -1
|
||||
#var turndirection = 1 if distance_fl<distance_fr else -1
|
||||
var turndirection = constrain((distance_fr-distance_fl)*turndirection_scale, -1,1)
|
||||
var steering_angle=constrain( remap(velocity.length(),steering_speed_fast,steering_speed_slow,steering_angle_fast,steering_angle_slow),steering_angle_fast,steering_angle_slow) #set maximum steering_angle based on speed
|
||||
|
||||
var steering_distance_far=constrain( remap(velocity.length(),steering_speed_fast,steering_speed_slow,steering_distance_far_fast,steering_distance_far_slow),steering_distance_far_fast,steering_distance_far_slow)
|
||||
var steering_distance_close=constrain( remap(velocity.length(),steering_speed_fast,steering_speed_slow,steering_distance_close_fast,steering_distance_close_slow),steering_distance_close_fast,steering_distance_close_slow)
|
||||
|
||||
steer_direction=0 #0=straight
|
||||
var steer_direction_aim=0 #0=straight
|
||||
if autosteer_enabled:
|
||||
if distance_min<steering_distance_far: #wall close, start steering away
|
||||
steer_direction += turndirection*deg_to_rad(constrain(remap(distance_min,steering_distance_far,steering_distance_close,0,steering_angle), 0,steering_angle))
|
||||
steer_direction_aim += turndirection*deg_to_rad(constrain(remap(distance_min,steering_distance_far,steering_distance_close,0,steering_angle), 0,steering_angle))
|
||||
|
||||
'''
|
||||
if Input.is_action_pressed("ui_left"):
|
||||
|
@ -223,6 +227,8 @@ func get_input(delta:float):
|
|||
steer_direction=1
|
||||
'''
|
||||
|
||||
steer_direction+=constrain(steer_direction_aim-steer_direction,max_steering_change*delta,-max_steering_change*delta)
|
||||
|
||||
applied_engine_power=0
|
||||
|
||||
var key_accelerator_pressed=Input.is_action_pressed(Gamestate.userinput_prefix+str(playerid))
|
||||
|
@ -260,6 +266,7 @@ func get_input(delta:float):
|
|||
if steer_direction<1:
|
||||
resetcar_steerangle=min(-resetcar_steerangle,+resetcar_steerangle) #calculate steering direction for next autoreset
|
||||
|
||||
$sprite_steeringwheel.rotation=steer_direction
|
||||
|
||||
func calculate_steering(delta:float):
|
||||
var rear_wheel = position - transform.x *wheel_base/2.0
|
||||
|
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 7 KiB |
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
BIN
sprites/bobbycar_steeringwheel.png
Normal file
BIN
sprites/bobbycar_steeringwheel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
34
sprites/bobbycar_steeringwheel.png.import
Normal file
34
sprites/bobbycar_steeringwheel.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dkg8e3stos5rw"
|
||||
path="res://.godot/imported/bobbycar_steeringwheel.png-9bb71ad08b2700fcbd05cc42941865e6.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sprites/bobbycar_steeringwheel.png"
|
||||
dest_files=["res://.godot/imported/bobbycar_steeringwheel.png-9bb71ad08b2700fcbd05cc42941865e6.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
Loading…
Reference in a new issue