weapon speed modifiers
This commit is contained in:
parent
ac8ea51d9c
commit
7c7f68b6f5
8 changed files with 37 additions and 21 deletions
|
|
@ -1,11 +1,12 @@
|
|||
extends State
|
||||
|
||||
@export var SPEED: float = 2.5
|
||||
@export var speed: float = 2.5
|
||||
@export var toggle: bool = false
|
||||
@export var stand_up_area: Area3D
|
||||
@export var player: Player
|
||||
@export var animation_player: AnimationPlayer
|
||||
@export var crouch_time: float = 0.1
|
||||
@export var weapon_system: WeaponSystem
|
||||
|
||||
func enter() -> void:
|
||||
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 direction := (player.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
var modified_speed = speed * weapon_system.get_speed_modifier()
|
||||
if direction:
|
||||
player.velocity.x = direction.x * SPEED
|
||||
player.velocity.z = direction.z * SPEED
|
||||
player.velocity.x = direction.x * modified_speed
|
||||
player.velocity.z = direction.z * modified_speed
|
||||
else:
|
||||
player.velocity.x = move_toward(player.velocity.x, 0, SPEED)
|
||||
player.velocity.z = move_toward(player.velocity.z, 0, SPEED)
|
||||
player.velocity.x = move_toward(player.velocity.x, 0, modified_speed)
|
||||
player.velocity.z = move_toward(player.velocity.z, 0, modified_speed)
|
||||
|
||||
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")):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
extends State
|
||||
|
||||
@export var SPEED: float = 5.0
|
||||
@export var speed: float = 5.0
|
||||
@export var JUMP_VELOCITY: float = 4.5
|
||||
@export var player: Player
|
||||
@export var weapon_system: WeaponSystem
|
||||
|
||||
func enter() -> void:
|
||||
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 direction := (player.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
var modified_speed := speed * weapon_system.get_speed_modifier()
|
||||
if direction:
|
||||
player.velocity.x = direction.x * SPEED
|
||||
player.velocity.z = direction.z * SPEED
|
||||
player.velocity.x = direction.x * modified_speed
|
||||
player.velocity.z = direction.z * modified_speed
|
||||
else:
|
||||
player.velocity.x = move_toward(player.velocity.x, 0, SPEED)
|
||||
player.velocity.z = move_toward(player.velocity.z, 0, SPEED)
|
||||
player.velocity.x = move_toward(player.velocity.x, 0, modified_speed)
|
||||
player.velocity.z = move_toward(player.velocity.z, 0, modified_speed)
|
||||
|
||||
func state_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("plr_crouch"):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
extends State
|
||||
|
||||
@export var SPEED: float = 2.5
|
||||
@export var speed: float = 2.5
|
||||
@export var JUMP_VELOCITY: float = 4.5
|
||||
@export var player: Player
|
||||
@export var weapon_system: WeaponSystem
|
||||
|
||||
func enter() -> void:
|
||||
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 direction := (player.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
var modified_speed = speed * weapon_system.get_speed_modifier()
|
||||
if direction:
|
||||
player.velocity.x = direction.x * SPEED
|
||||
player.velocity.z = direction.z * SPEED
|
||||
player.velocity.x = direction.x * modified_speed
|
||||
player.velocity.z = direction.z * modified_speed
|
||||
else:
|
||||
player.velocity.x = move_toward(player.velocity.x, 0, SPEED)
|
||||
player.velocity.z = move_toward(player.velocity.z, 0, SPEED)
|
||||
player.velocity.x = move_toward(player.velocity.x, 0, modified_speed)
|
||||
player.velocity.z = move_toward(player.velocity.z, 0, modified_speed)
|
||||
|
||||
func state_input(event: InputEvent) -> void:
|
||||
if event.is_action_released("plr_walk"):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue