update changes IT ALMOST WORKS
This commit is contained in:
parent
7bf0b39d60
commit
aaaa8a80a5
@ -55,13 +55,12 @@ func _physics_process(delta: float) -> void:
|
|||||||
if is_piloting:
|
if is_piloting:
|
||||||
# global_transform.basis = current_ship.global_transform.basis
|
# global_transform.basis = current_ship.global_transform.basis
|
||||||
global_rotation.y = current_ship.global_rotation.y
|
global_rotation.y = current_ship.global_rotation.y
|
||||||
velocity = walk(delta) + _gravity(delta) + _jump(delta)
|
|
||||||
else:
|
else:
|
||||||
velocity = walk(delta) + _gravity(delta) + _jump(delta)
|
velocity = walk(delta) + _gravity(delta) + _jump(delta)
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
velocity = walk(delta) + _gravity(delta) + _jump(delta)
|
velocity = walk(delta) + _gravity(delta) + _jump(delta)
|
||||||
|
|
||||||
global_rotation.x = 0.0
|
global_rotation.x = 0.0
|
||||||
global_rotation.z = 0.0
|
global_rotation.z = 0.0
|
||||||
|
|
||||||
@ -98,7 +97,8 @@ func _handle_joypad_camera_rotation(delta: float, sens_mod: float = 1.0) -> void
|
|||||||
func walk(delta: float) -> Vector3:
|
func walk(delta: float) -> Vector3:
|
||||||
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||||
move_dir = Input.get_vector("move_left", "move_right", "move_forwards", "move_backwards")
|
move_dir = Input.get_vector("move_left", "move_right", "move_forwards", "move_backwards")
|
||||||
var walk_dir: Vector3 = Vector3(move_dir.x, 0, move_dir.y).normalized()
|
var _forward: Vector3 = camera.global_transform.basis * Vector3(move_dir.x, 0, move_dir.y)
|
||||||
|
var walk_dir: Vector3 = Vector3(_forward.x, 0, _forward.z).normalized()
|
||||||
walk_vel = walk_vel.move_toward(walk_dir * speed * move_dir.length(), acceleration * delta)
|
walk_vel = walk_vel.move_toward(walk_dir * speed * move_dir.length(), acceleration * delta)
|
||||||
return walk_vel
|
return walk_vel
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ var ship_is_piloted: bool = false
|
|||||||
@export var move_speed: float = 10.0
|
@export var move_speed: float = 10.0
|
||||||
@export var acceleration: float = 10.0
|
@export var acceleration: float = 10.0
|
||||||
@export var deceleration: float = 20.0
|
@export var deceleration: float = 20.0
|
||||||
|
var player_on_ship: bool = false
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
@ -48,12 +49,13 @@ func _physics_process(delta):
|
|||||||
elif Input.is_action_pressed("crouch"):
|
elif Input.is_action_pressed("crouch"):
|
||||||
linear_velocity.y -= lift_speed
|
linear_velocity.y -= lift_speed
|
||||||
|
|
||||||
if Input.is_action_pressed("move_forwards"):
|
if player_on_ship:
|
||||||
var forward_force = (((-transform.basis.z * move_speed) - linear_velocity) * mass).normalized()
|
if Input.is_action_pressed("move_forwards"):
|
||||||
apply_central_force(forward_force)
|
var forward_force = (((-transform.basis.z * move_speed) - linear_velocity) * mass).normalized()
|
||||||
elif Input.is_action_pressed("move_backwards"):
|
apply_central_force(forward_force)
|
||||||
var forward_force = (((transform.basis.z * move_speed) - linear_velocity) * mass).normalized()
|
elif Input.is_action_pressed("move_backwards"):
|
||||||
apply_central_force(forward_force)
|
var forward_force = (((transform.basis.z * move_speed) - linear_velocity) * mass).normalized()
|
||||||
|
apply_central_force(forward_force)
|
||||||
|
|
||||||
|
|
||||||
angular_velocity.y = clamp(angular_velocity.y, -max_turn_speed, max_turn_speed)
|
angular_velocity.y = clamp(angular_velocity.y, -max_turn_speed, max_turn_speed)
|
||||||
@ -65,10 +67,12 @@ func _physics_process(delta):
|
|||||||
|
|
||||||
func _on_area_3d_body_entered(body):
|
func _on_area_3d_body_entered(body):
|
||||||
if body is Player:
|
if body is Player:
|
||||||
|
print(self.name)
|
||||||
body.player_entered_ship(global_position, self)
|
body.player_entered_ship(global_position, self)
|
||||||
piloting_player = body
|
piloting_player = body
|
||||||
print(self.name)
|
if !player_on_ship:
|
||||||
body.reparent(self, true)
|
body.reparent(self, true)
|
||||||
|
player_on_ship = true
|
||||||
|
|
||||||
|
|
||||||
func _on_area_3d_body_exited(body):
|
func _on_area_3d_body_exited(body):
|
||||||
@ -76,7 +80,9 @@ func _on_area_3d_body_exited(body):
|
|||||||
body.player_exited_ship(global_position, self)
|
body.player_exited_ship(global_position, self)
|
||||||
ship_is_piloted = false
|
ship_is_piloted = false
|
||||||
piloting_player = null
|
piloting_player = null
|
||||||
body.reparent(get_node("/root/Devlevel"), true)
|
if player_on_ship:
|
||||||
|
body.reparent(get_node("/root/DevLevel/"), true)
|
||||||
|
player_on_ship = false
|
||||||
|
|
||||||
|
|
||||||
func _add_ship_helm(_ship_helm_scene: PackedScene):
|
func _add_ship_helm(_ship_helm_scene: PackedScene):
|
||||||
|
Loading…
Reference in New Issue
Block a user