weapon speed modifiers
This commit is contained in:
parent
ac8ea51d9c
commit
7c7f68b6f5
8 changed files with 37 additions and 21 deletions
|
|
@ -268,23 +268,23 @@ script = ExtResource("8_f1ej7")
|
||||||
current_state = NodePath("Stand")
|
current_state = NodePath("Stand")
|
||||||
metadata/_custom_type_script = "uid://3777rkbebgjm"
|
metadata/_custom_type_script = "uid://3777rkbebgjm"
|
||||||
|
|
||||||
[node name="Crouch" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("stand_up_area", "player", "animation_player")]
|
[node name="Crouch" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("stand_up_area", "player", "animation_player", "weapon_system")]
|
||||||
script = ExtResource("9_oprun")
|
script = ExtResource("9_oprun")
|
||||||
SPEED = 3.125
|
|
||||||
stand_up_area = NodePath("../../StandArea")
|
stand_up_area = NodePath("../../StandArea")
|
||||||
player = NodePath("../..")
|
player = NodePath("../..")
|
||||||
animation_player = NodePath("../../AnimationPlayer")
|
animation_player = NodePath("../../AnimationPlayer")
|
||||||
|
weapon_system = NodePath("../../WeaponSystem")
|
||||||
|
|
||||||
[node name="Stand" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("player")]
|
[node name="Stand" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("player", "weapon_system")]
|
||||||
script = ExtResource("10_a8ls1")
|
script = ExtResource("10_a8ls1")
|
||||||
SPEED = 6.25
|
|
||||||
JUMP_VELOCITY = 6.0
|
JUMP_VELOCITY = 6.0
|
||||||
player = NodePath("../..")
|
player = NodePath("../..")
|
||||||
|
weapon_system = NodePath("../../WeaponSystem")
|
||||||
|
|
||||||
[node name="Walk" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("player")]
|
[node name="Walk" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("player", "weapon_system")]
|
||||||
script = ExtResource("11_qfm1y")
|
script = ExtResource("11_qfm1y")
|
||||||
SPEED = 3.125
|
|
||||||
player = NodePath("../..")
|
player = NodePath("../..")
|
||||||
|
weapon_system = NodePath("../../WeaponSystem")
|
||||||
|
|
||||||
[node name="Fall" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("player")]
|
[node name="Fall" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("player")]
|
||||||
script = ExtResource("12_fulsm")
|
script = ExtResource("12_fulsm")
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ animation_prefix = &"baked_sp_"
|
||||||
droppable = &"uid://dgfqppi21c2u0"
|
droppable = &"uid://dgfqppi21c2u0"
|
||||||
visibility_target = &"sp"
|
visibility_target = &"sp"
|
||||||
max_ammo = 20
|
max_ammo = 20
|
||||||
|
speed_modifier = 0.9
|
||||||
slot = &"secondary"
|
slot = &"secondary"
|
||||||
enter_state = NodePath("Intro")
|
enter_state = NodePath("Intro")
|
||||||
metadata/_custom_type_script = "uid://e6lqknfl4ngt"
|
metadata/_custom_type_script = "uid://e6lqknfl4ngt"
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
extends State
|
extends State
|
||||||
|
|
||||||
@export var SPEED: float = 2.5
|
@export var speed: float = 2.5
|
||||||
@export var toggle: bool = false
|
@export var toggle: bool = false
|
||||||
@export var stand_up_area: Area3D
|
@export var stand_up_area: Area3D
|
||||||
@export var player: Player
|
@export var player: Player
|
||||||
@export var animation_player: AnimationPlayer
|
@export var animation_player: AnimationPlayer
|
||||||
@export var crouch_time: float = 0.1
|
@export var crouch_time: float = 0.1
|
||||||
|
@export var weapon_system: WeaponSystem
|
||||||
|
|
||||||
func enter() -> void:
|
func enter() -> void:
|
||||||
animation_player.play("crouch",-1,1/crouch_time)
|
animation_player.play("crouch",-1,1/crouch_time)
|
||||||
|
|
@ -26,12 +27,13 @@ func physics_update(_delta: float) -> void:
|
||||||
|
|
||||||
var input_dir := Input.get_vector("plr_strafe_r","plr_strafe_l", "plr_back","plr_forward")
|
var input_dir := Input.get_vector("plr_strafe_r","plr_strafe_l", "plr_back","plr_forward")
|
||||||
var direction := (player.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
var direction := (player.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||||
|
var modified_speed = speed * weapon_system.get_speed_modifier()
|
||||||
if direction:
|
if direction:
|
||||||
player.velocity.x = direction.x * SPEED
|
player.velocity.x = direction.x * modified_speed
|
||||||
player.velocity.z = direction.z * SPEED
|
player.velocity.z = direction.z * modified_speed
|
||||||
else:
|
else:
|
||||||
player.velocity.x = move_toward(player.velocity.x, 0, SPEED)
|
player.velocity.x = move_toward(player.velocity.x, 0, modified_speed)
|
||||||
player.velocity.z = move_toward(player.velocity.z, 0, SPEED)
|
player.velocity.z = move_toward(player.velocity.z, 0, modified_speed)
|
||||||
|
|
||||||
func state_input(event: InputEvent) -> void:
|
func state_input(event: InputEvent) -> void:
|
||||||
if (toggle == true and event.is_action_pressed("plr_crouch")) or (toggle == false and event.is_action_released("plr_crouch")):
|
if (toggle == true and event.is_action_pressed("plr_crouch")) or (toggle == false and event.is_action_released("plr_crouch")):
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
extends State
|
extends State
|
||||||
|
|
||||||
@export var SPEED: float = 5.0
|
@export var speed: float = 5.0
|
||||||
@export var JUMP_VELOCITY: float = 4.5
|
@export var JUMP_VELOCITY: float = 4.5
|
||||||
@export var player: Player
|
@export var player: Player
|
||||||
|
@export var weapon_system: WeaponSystem
|
||||||
|
|
||||||
func enter() -> void:
|
func enter() -> void:
|
||||||
pass
|
pass
|
||||||
|
|
@ -24,12 +25,13 @@ func physics_update(_delta: float) -> void:
|
||||||
|
|
||||||
var input_dir := Input.get_vector("plr_strafe_r","plr_strafe_l", "plr_back","plr_forward")
|
var input_dir := Input.get_vector("plr_strafe_r","plr_strafe_l", "plr_back","plr_forward")
|
||||||
var direction := (player.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
var direction := (player.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||||
|
var modified_speed := speed * weapon_system.get_speed_modifier()
|
||||||
if direction:
|
if direction:
|
||||||
player.velocity.x = direction.x * SPEED
|
player.velocity.x = direction.x * modified_speed
|
||||||
player.velocity.z = direction.z * SPEED
|
player.velocity.z = direction.z * modified_speed
|
||||||
else:
|
else:
|
||||||
player.velocity.x = move_toward(player.velocity.x, 0, SPEED)
|
player.velocity.x = move_toward(player.velocity.x, 0, modified_speed)
|
||||||
player.velocity.z = move_toward(player.velocity.z, 0, SPEED)
|
player.velocity.z = move_toward(player.velocity.z, 0, modified_speed)
|
||||||
|
|
||||||
func state_input(event: InputEvent) -> void:
|
func state_input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("plr_crouch"):
|
if event.is_action_pressed("plr_crouch"):
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
extends State
|
extends State
|
||||||
|
|
||||||
@export var SPEED: float = 2.5
|
@export var speed: float = 2.5
|
||||||
@export var JUMP_VELOCITY: float = 4.5
|
@export var JUMP_VELOCITY: float = 4.5
|
||||||
@export var player: Player
|
@export var player: Player
|
||||||
|
@export var weapon_system: WeaponSystem
|
||||||
|
|
||||||
func enter() -> void:
|
func enter() -> void:
|
||||||
pass
|
pass
|
||||||
|
|
@ -24,12 +25,13 @@ func physics_update(_delta: float) -> void:
|
||||||
|
|
||||||
var input_dir := Input.get_vector("plr_strafe_r","plr_strafe_l", "plr_back","plr_forward")
|
var input_dir := Input.get_vector("plr_strafe_r","plr_strafe_l", "plr_back","plr_forward")
|
||||||
var direction := (player.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
var direction := (player.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||||
|
var modified_speed = speed * weapon_system.get_speed_modifier()
|
||||||
if direction:
|
if direction:
|
||||||
player.velocity.x = direction.x * SPEED
|
player.velocity.x = direction.x * modified_speed
|
||||||
player.velocity.z = direction.z * SPEED
|
player.velocity.z = direction.z * modified_speed
|
||||||
else:
|
else:
|
||||||
player.velocity.x = move_toward(player.velocity.x, 0, SPEED)
|
player.velocity.x = move_toward(player.velocity.x, 0, modified_speed)
|
||||||
player.velocity.z = move_toward(player.velocity.z, 0, SPEED)
|
player.velocity.z = move_toward(player.velocity.z, 0, modified_speed)
|
||||||
|
|
||||||
func state_input(event: InputEvent) -> void:
|
func state_input(event: InputEvent) -> void:
|
||||||
if event.is_action_released("plr_walk"):
|
if event.is_action_released("plr_walk"):
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,11 @@ const active_bomb: StringName = "uid://dtbpyfdawb02b"
|
||||||
func enter():
|
func enter():
|
||||||
machine.animation_player.play(machine.animation_prefix+"plant")
|
machine.animation_player.play(machine.animation_prefix+"plant")
|
||||||
machine.animation_player.animation_finished.connect(on_animation_finished)
|
machine.animation_player.animation_finished.connect(on_animation_finished)
|
||||||
|
machine.speed_modifier = 0.0
|
||||||
|
|
||||||
func exit():
|
func exit():
|
||||||
machine.animation_player.animation_finished.disconnect(on_animation_finished)
|
machine.animation_player.animation_finished.disconnect(on_animation_finished)
|
||||||
|
machine.speed_modifier = 1.0
|
||||||
|
|
||||||
func on_animation_finished(animation: StringName):
|
func on_animation_finished(animation: StringName):
|
||||||
if animation == machine.animation_prefix + "plant":
|
if animation == machine.animation_prefix + "plant":
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ class_name WeaponSubStateMachine
|
||||||
@onready var ammo: int = max_ammo
|
@onready var ammo: int = max_ammo
|
||||||
@onready var remaining_ammo: int = max_ammo * 3
|
@onready var remaining_ammo: int = max_ammo * 3
|
||||||
|
|
||||||
|
@export var speed_modifier: float = 1.0
|
||||||
|
|
||||||
@export var can_be_previous: bool = true
|
@export var can_be_previous: bool = true
|
||||||
@export var destroy_when_empty: bool = false
|
@export var destroy_when_empty: bool = false
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,11 @@ signal switched_to(state: WeaponSubStateMachine)
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
$WeaponSpawner.spawn_function = pick_up_weapon
|
$WeaponSpawner.spawn_function = pick_up_weapon
|
||||||
|
|
||||||
|
func get_speed_modifier() -> float:
|
||||||
|
if current_state == null:
|
||||||
|
return 1
|
||||||
|
return current_state.speed_modifier
|
||||||
|
|
||||||
func can_add(slot: StringName) -> bool:
|
func can_add(slot: StringName) -> bool:
|
||||||
return slots.has(slot) and slots[slot] == null
|
return slots.has(slot) and slots[slot] == null
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue