mirror of
https://github.com/FOSS-Supremacy/OpenLiberty.git
synced 2025-04-28 11:57:58 +03:00
feat: vehicle main script
This commit is contained in:
parent
705f9fc624
commit
0fc94b2fd2
1 changed files with 29 additions and 38 deletions
|
@ -1,4 +1,14 @@
|
|||
|
||||
#<--->
|
||||
# Still under development. It is not practical to use this script in other vehicles.
|
||||
# If you add this script to other vehicles, you will need a series of corrections
|
||||
# in the script due to lack of resources in the scene. Such as "$ExitMarked", "$VehicleCameraController",
|
||||
# "$InteractArea", etc...
|
||||
#<--->
|
||||
|
||||
extends VehicleBody3D
|
||||
class_name VehicleHead
|
||||
|
||||
@export var state:VehicleState = VehicleState.STOPPED
|
||||
enum VehicleState {
|
||||
PLAYER_DRIVING,
|
||||
|
@ -8,22 +18,9 @@ enum VehicleState {
|
|||
|
||||
var speed = 0
|
||||
|
||||
@export_group("General Properties")
|
||||
@export var VehicleMass: = 0 ## Define a massa do veículo em quilogramas (kg).
|
||||
@export var CenterOfMass = Vector3(0,0,0) ## Define a massa do veículo em quilogramas (kg).
|
||||
@export_group("Suspension Settings")
|
||||
@export var suspension_stiffness = 0 ## Define quão rígida ou macia é a suspensão. Valores mais altos resultam em uma suspensão mais rígida.
|
||||
@export_group("Wheel Settings")
|
||||
@export var tire_grip = 0 ## Define quanta tração os pneus têm na superfície. Valores mais altos resultam em melhor aderência.
|
||||
@export var wheel_radius = 0 ## Define o tamanho das rodas, o que afeta a altura do veículo e o comportamento de direção.
|
||||
@export var wheel_friction_slip = 0 ## Controla a quantidade de derrapagem que ocorre durante a direção. Valores mais baixos permitem mais deslizamento.
|
||||
@export_group("Braking Settings")
|
||||
@export var brake_force = 0 ## Define a força aplicada aos freios. Afeta a eficiência da frenagem.
|
||||
@export var handbrake_force = 0 ## Define a força aplicada pelo freio de mão, geralmente usada para travar as rodas traseiras.
|
||||
@export_group("Other Settings")
|
||||
@export var downforce = 0 ## Simula a pressão aerodinâmica que empurra o carro para baixo, aumentando a aderência em altas velocidades.
|
||||
@export var traction_control:bool = false ## Controle de tração, que impede que as rodas patinem durante a aceleração.
|
||||
@export var abs:bool = false ## Sistema de freio ABS, que impede que as rodas travem durante a frenagem.
|
||||
@export_group("Vehicle Nodes")
|
||||
@export var VehicleEnginePath:VehicleEngine
|
||||
@export var VehicleSteeringPath:VehicleSteering
|
||||
|
||||
@onready var driver: Node3D = $CarView/Driver
|
||||
|
||||
|
@ -37,17 +34,17 @@ var camera_rotation = 0.0
|
|||
|
||||
func _physics_process(delta):
|
||||
StateController() # Controlador do estado do carro.
|
||||
|
||||
match state:
|
||||
VehicleState.PLAYER_DRIVING:
|
||||
$VehicleNodes/VehicleEngine.EngineController()
|
||||
$VehicleNodes/VehicleSteering.SteerVehicle(delta)
|
||||
VehicleState.STOPPED:
|
||||
$VehicleNodes/VehicleEngine.EngineBrake()
|
||||
|
||||
#DriverController(delta)
|
||||
|
||||
EnterAndExit() # Mecanica de entrar e sair do carro.
|
||||
|
||||
if VehicleEnginePath != null and VehicleSteeringPath != null:
|
||||
match state:
|
||||
VehicleState.PLAYER_DRIVING: # Se o jogador estiver dirigindo:
|
||||
VehicleEnginePath.EngineController()
|
||||
VehicleSteeringPath.SteerVehicle(delta)
|
||||
VehicleState.STOPPED: # Se o jogador não estiver dirigindo:
|
||||
VehicleEnginePath.EngineBrake()
|
||||
else:
|
||||
print("Vehicle nodes not found.")
|
||||
|
||||
func StateController(): # Car state controller
|
||||
# <--->
|
||||
|
@ -61,9 +58,11 @@ func StateController(): # Car state controller
|
|||
if state == VehicleState.PLAYER_DRIVING: # Define alguns parametros quando o jogador está ou não no carro.
|
||||
driver.show()
|
||||
$CarInterface/VBoxContainer.show()
|
||||
#else:
|
||||
#driver.hide()
|
||||
#$CarInterface/VBoxContainer.hide()
|
||||
else:
|
||||
driver.hide()
|
||||
$CarInterface/VBoxContainer.hide()
|
||||
|
||||
|
||||
# <--->
|
||||
if player_in_area: # Usado para definir se o jogador pode ou não interagir com o carro.
|
||||
if state == VehicleState.STOPPED:
|
||||
|
@ -73,14 +72,7 @@ func StateController(): # Car state controller
|
|||
else:
|
||||
player_can_interact = false
|
||||
# <--->
|
||||
|
||||
func DriverController(delta): # Mecanica de dirigir.
|
||||
if state == VehicleState.PLAYER_DRIVING:
|
||||
pass
|
||||
|
||||
elif state == VehicleState.STOPPED:
|
||||
pass
|
||||
|
||||
|
||||
func EnterAndExit(): # Mecanica de entrar e sair do carro.
|
||||
if Input.is_action_just_pressed("enter_car") and player != null:
|
||||
if state == VehicleState.STOPPED:
|
||||
|
@ -97,7 +89,6 @@ func PlayerEnteredInteractArea(body: Node3D) -> void:
|
|||
player = body
|
||||
player_can_interact = true
|
||||
player_in_area = true
|
||||
|
||||
func PlayerExitedInteractArea(body: Node3D) -> void:
|
||||
if body is Player:
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue