Single rotation and force
This commit is contained in:
parent
ccd94eed31
commit
d520c17010
@ -10,10 +10,10 @@ extends RigidBody3D
|
|||||||
@export var armed: bool = false
|
@export var armed: bool = false
|
||||||
@export var can_flip: bool = false
|
@export var can_flip: bool = false
|
||||||
@export var throttle_speed: float = 0.0
|
@export var throttle_speed: float = 0.0
|
||||||
@export var rotation_speed: float = 0.5
|
@export var rotation_speed: float = 0.15
|
||||||
@export var max_speed: float = 100.0
|
@export var max_speed: float = 20.0
|
||||||
@export var max_rotation_speed: float = 15.0
|
@export var max_rotation_speed: float = 15.0
|
||||||
@export var camera_tilt_angle: float = 0.0
|
@export var thrust_factor: float = 1.0
|
||||||
@export_category("Node References")
|
@export_category("Node References")
|
||||||
@export var camera: Camera3D
|
@export var camera: Camera3D
|
||||||
@export var anim_player: AnimationPlayer
|
@export var anim_player: AnimationPlayer
|
||||||
@ -35,22 +35,6 @@ func _process(_delta):
|
|||||||
handle_arming()
|
handle_arming()
|
||||||
|
|
||||||
|
|
||||||
func handle_throttle(throttle_input: float):
|
|
||||||
if using_joy_controller:
|
|
||||||
if throttle_input > 0:
|
|
||||||
throttle_speed = throttle_input * 100
|
|
||||||
apply_central_force(global_transform.basis.y * throttle_speed)
|
|
||||||
|
|
||||||
# Speed scale adjusted for animation
|
|
||||||
anim_player.speed_scale = throttle_input * 4
|
|
||||||
anim_player.speed_scale = clampf(anim_player.speed_scale, 1.0, 4.0)
|
|
||||||
|
|
||||||
linear_velocity.x = clampf(linear_velocity.x, -max_speed, max_speed)
|
|
||||||
linear_velocity.y = clampf(linear_velocity.y, -max_speed, max_speed)
|
|
||||||
linear_velocity.z = clampf(linear_velocity.z, -max_speed, max_speed)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func handle_arming():
|
func handle_arming():
|
||||||
if !armed:
|
if !armed:
|
||||||
if !animation_initalized:
|
if !animation_initalized:
|
||||||
@ -78,6 +62,8 @@ func _on_flip_over_timeout():
|
|||||||
can_flip = true
|
can_flip = true
|
||||||
input_suggestion_label.text = "press A to flip drone"
|
input_suggestion_label.text = "press A to flip drone"
|
||||||
input_suggestion_label.show()
|
input_suggestion_label.show()
|
||||||
|
else:
|
||||||
|
input_suggestion_label.hide()
|
||||||
|
|
||||||
|
|
||||||
func _handle_drone_flipping():
|
func _handle_drone_flipping():
|
||||||
@ -85,6 +71,8 @@ func _handle_drone_flipping():
|
|||||||
global_rotation = Vector3.ZERO
|
global_rotation = Vector3.ZERO
|
||||||
input_suggestion_label.hide()
|
input_suggestion_label.hide()
|
||||||
can_flip = false
|
can_flip = false
|
||||||
|
else:
|
||||||
|
input_suggestion_label.hide()
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(_delta): # Still needed for other physics
|
func _physics_process(_delta): # Still needed for other physics
|
||||||
@ -103,14 +91,25 @@ func _input(event):
|
|||||||
angular_velocity = Vector3.ZERO
|
angular_velocity = Vector3.ZERO
|
||||||
|
|
||||||
|
|
||||||
func _integrate_forces(state): # Use _integrate_forces for RigidBody3D control
|
func _integrate_forces(state):
|
||||||
if armed and GameManager.game_started: # Only apply controls when armed and when the game has started
|
if armed and GameManager.game_started:
|
||||||
var yaw_input = Input.get_axis("yaw_right", "yaw_left")
|
var yaw_input = Input.get_axis("yaw_right", "yaw_left")
|
||||||
var roll_input = Input.get_axis("roll_right", "roll_left")
|
var roll_input = Input.get_axis("roll_right", "roll_left")
|
||||||
var pitch_input = Input.get_axis("pitch_backward", "pitch_forward")
|
var pitch_input = Input.get_axis("pitch_backward", "pitch_forward")
|
||||||
var throttle_input = Input.get_axis("throttle_down", "throttle_up")
|
var throttle_input = Input.get_axis("throttle_down", "throttle_up")
|
||||||
|
|
||||||
|
if using_joy_controller:
|
||||||
|
if throttle_input > 0:
|
||||||
|
throttle_speed = throttle_input * 100
|
||||||
|
apply_central_force(global_transform.basis.y * throttle_speed * thrust_factor)
|
||||||
|
|
||||||
|
linear_velocity.x = clampf(linear_velocity.x, -max_speed, max_speed)
|
||||||
|
linear_velocity.y = clampf(linear_velocity.y, -100.0, max_speed)
|
||||||
|
linear_velocity.z = clampf(linear_velocity.z, -max_speed, max_speed)
|
||||||
|
|
||||||
handle_throttle(throttle_input) # Throttle handled here
|
# Speed scale adjusted for animation
|
||||||
|
anim_player.speed_scale = throttle_input * 4
|
||||||
|
anim_player.speed_scale = clampf(anim_player.speed_scale, 1.0, 4.0)
|
||||||
|
|
||||||
if yaw_input != 0:
|
if yaw_input != 0:
|
||||||
rotate_object_local(Vector3.UP, yaw_input * rotation_speed) # Y axis rotation
|
rotate_object_local(Vector3.UP, yaw_input * rotation_speed) # Y axis rotation
|
||||||
@ -126,8 +125,3 @@ func _integrate_forces(state): # Use _integrate_forces for RigidBody3D control
|
|||||||
state.angular_velocity.z = lerp(state.angular_velocity.z, 0.0, 0.05)
|
state.angular_velocity.z = lerp(state.angular_velocity.z, 0.0, 0.05)
|
||||||
if pitch_input == 0:
|
if pitch_input == 0:
|
||||||
state.angular_velocity.x = lerp(state.angular_velocity.x, 0.0, 0.05)
|
state.angular_velocity.x = lerp(state.angular_velocity.x, 0.0, 0.05)
|
||||||
|
|
||||||
# Clamp the angular velocity
|
|
||||||
state.angular_velocity.y = clampf(state.angular_velocity.y, -max_rotation_speed, max_rotation_speed)
|
|
||||||
state.angular_velocity.z = clampf(state.angular_velocity.z, -max_rotation_speed, max_rotation_speed)
|
|
||||||
state.angular_velocity.x = clampf(state.angular_velocity.x, -max_rotation_speed, max_rotation_speed)
|
|
||||||
|
@ -1071,10 +1071,10 @@ shadow_mesh = SubResource("ArrayMesh_oy56j")
|
|||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_pkxv0"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_pkxv0"]
|
||||||
shader = ExtResource("9_66bpw")
|
shader = ExtResource("9_66bpw")
|
||||||
shader_parameter/curvature = 0.0
|
shader_parameter/curvature = 0.0
|
||||||
shader_parameter/skip = 0.05
|
shader_parameter/skip = 0.01
|
||||||
shader_parameter/image_flicker = 0.06
|
shader_parameter/image_flicker = 0.01
|
||||||
shader_parameter/vignette_flicker_speed = 0.0
|
shader_parameter/vignette_flicker_speed = 0.0
|
||||||
shader_parameter/vignette_strength = 1.0
|
shader_parameter/vignette_strength = 0.0
|
||||||
shader_parameter/small_scanlines_speed = 1.0
|
shader_parameter/small_scanlines_speed = 1.0
|
||||||
shader_parameter/small_scanlines_proximity = 1.0
|
shader_parameter/small_scanlines_proximity = 1.0
|
||||||
shader_parameter/small_scanlines_opacity = 0.31
|
shader_parameter/small_scanlines_opacity = 0.31
|
||||||
@ -1087,11 +1087,11 @@ shader_parameter/noise_texture = ExtResource("10_ylv8e")
|
|||||||
[node name="Drone" type="RigidBody3D" node_paths=PackedStringArray("camera", "anim_player", "flip_over_detection_ray", "flip_over_timer", "input_suggestion_label")]
|
[node name="Drone" type="RigidBody3D" node_paths=PackedStringArray("camera", "anim_player", "flip_over_detection_ray", "flip_over_timer", "input_suggestion_label")]
|
||||||
collision_layer = 2
|
collision_layer = 2
|
||||||
collision_mask = 7
|
collision_mask = 7
|
||||||
|
mass = 0.6
|
||||||
physics_material_override = SubResource("PhysicsMaterial_kpx62")
|
physics_material_override = SubResource("PhysicsMaterial_kpx62")
|
||||||
can_sleep = false
|
can_sleep = false
|
||||||
|
continuous_cd = true
|
||||||
script = ExtResource("1_de83i")
|
script = ExtResource("1_de83i")
|
||||||
rotation_speed = 0.08
|
|
||||||
max_speed = 10.0
|
|
||||||
camera = NodePath("VisualComponets/CameraPivot/Camera3D")
|
camera = NodePath("VisualComponets/CameraPivot/Camera3D")
|
||||||
anim_player = NodePath("AnimationPlayer")
|
anim_player = NodePath("AnimationPlayer")
|
||||||
flip_over_detection_ray = NodePath("FlipOverDetectionRay")
|
flip_over_detection_ray = NodePath("FlipOverDetectionRay")
|
||||||
@ -1321,6 +1321,7 @@ script = ExtResource("9_8eblv")
|
|||||||
[node name="CanvasLayer" type="CanvasLayer" parent="VisualComponets/CameraPivot/Camera3D"]
|
[node name="CanvasLayer" type="CanvasLayer" parent="VisualComponets/CameraPivot/Camera3D"]
|
||||||
|
|
||||||
[node name="VHSVFX" type="Control" parent="VisualComponets/CameraPivot/Camera3D/CanvasLayer"]
|
[node name="VHSVFX" type="Control" parent="VisualComponets/CameraPivot/Camera3D/CanvasLayer"]
|
||||||
|
visible = false
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
BIN
godot-jolt/windows/~godot-jolt_windows-x64_editor.dll
Normal file
BIN
godot-jolt/windows/~godot-jolt_windows-x64_editor.dll
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user