crouch fixed
This commit is contained in:
parent
7bbeebdd2e
commit
276ff0252b
11 changed files with 167 additions and 115 deletions
21
scripts/debug/property_shower.gd
Normal file
21
scripts/debug/property_shower.gd
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
extends VBoxContainer
|
||||
|
||||
@export var property_array: Dictionary[NodePath,StringName]
|
||||
|
||||
func _ready() -> void:
|
||||
for target in property_array.keys():
|
||||
var hbox = HBoxContainer.new()
|
||||
var name_label = Label.new()
|
||||
var splitted = property_array[target].split(":")
|
||||
name_label.text = splitted[len(splitted)-1]
|
||||
name_label.name = "Name"
|
||||
var value_label = Label.new()
|
||||
value_label.name = "Value"
|
||||
hbox.add_child(name_label,true)
|
||||
hbox.add_child(value_label,true)
|
||||
hbox.name = str(target).replace("/","_").replace(".","")
|
||||
add_child(hbox,true)
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
for target in property_array:
|
||||
get_node(str(target).replace("/","_").replace(".","")+"/Value").text = str(get_node(target).get(property_array[target]))
|
||||
1
scripts/debug/property_shower.gd.uid
Normal file
1
scripts/debug/property_shower.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://7gmgcaxfh8sb
|
||||
|
|
@ -8,10 +8,10 @@ extends State
|
|||
@export var crouch_time: float = 0.1
|
||||
|
||||
func enter() -> void:
|
||||
animation_player.play("Crouch",-1,1/crouch_time)
|
||||
animation_player.play("crouch",-1,1/crouch_time)
|
||||
|
||||
func exit() -> void:
|
||||
animation_player.play("Crouch",-1,-1/crouch_time,true)
|
||||
animation_player.play("crouch",-1,-1/crouch_time,true)
|
||||
|
||||
func physics_update(_delta: float) -> void:
|
||||
if not is_multiplayer_authority():
|
||||
|
|
@ -33,9 +33,7 @@ func physics_update(_delta: float) -> void:
|
|||
player.velocity.x = move_toward(player.velocity.x, 0, SPEED)
|
||||
player.velocity.z = move_toward(player.velocity.z, 0, SPEED)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
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 stand_up_area.has_overlapping_bodies() == false:
|
||||
transition.emit("Stand")
|
||||
|
|
|
|||
|
|
@ -31,10 +31,7 @@ func physics_update(_delta: float) -> void:
|
|||
player.velocity.x = move_toward(player.velocity.x, 0, SPEED)
|
||||
player.velocity.z = move_toward(player.velocity.z, 0, SPEED)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
|
||||
func state_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("plr_crouch"):
|
||||
transition.emit("Crouch")
|
||||
|
||||
|
|
|
|||
|
|
@ -31,9 +31,7 @@ func physics_update(_delta: float) -> void:
|
|||
player.velocity.x = move_toward(player.velocity.x, 0, SPEED)
|
||||
player.velocity.z = move_toward(player.velocity.z, 0, SPEED)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
func state_input(event: InputEvent) -> void:
|
||||
if event.is_action_released("plr_walk"):
|
||||
transition.emit("Stand")
|
||||
|
||||
|
|
|
|||
|
|
@ -9,17 +9,19 @@ func _ready() -> void:
|
|||
for child in get_children():
|
||||
if child is State:
|
||||
states[child.name] = child
|
||||
child.transition.connect(on_transition_required.rpc)
|
||||
child.transition.connect(on_transition_required)
|
||||
else:
|
||||
push_warning("Child of state machine is not state")
|
||||
|
||||
@rpc("authority","call_local","reliable")
|
||||
func on_transition_required(to: StringName):
|
||||
if is_multiplayer_authority() == false:
|
||||
return
|
||||
if states.has(to) == false:
|
||||
push_warning("Incorrect state request: " + to)
|
||||
return
|
||||
|
||||
change_state(states[to])
|
||||
change_state_to_name.rpc(to)
|
||||
|
||||
func change_state(to_state: State) -> void:
|
||||
if current_state != null:
|
||||
|
|
@ -27,6 +29,13 @@ func change_state(to_state: State) -> void:
|
|||
current_state = to_state
|
||||
current_state.enter()
|
||||
|
||||
@rpc
|
||||
func change_state_to_name(to_name: StringName):
|
||||
if current_state != null:
|
||||
current_state.exit()
|
||||
current_state = states[to_name]
|
||||
current_state.enter()
|
||||
|
||||
@rpc("authority","call_local","unreliable")
|
||||
func clear_state():
|
||||
if current_state == null:
|
||||
|
|
@ -39,6 +48,10 @@ func _process(delta: float) -> void:
|
|||
return
|
||||
current_state.update(delta)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if current_state != null:
|
||||
current_state.state_input(event)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if current_state == null:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -13,3 +13,5 @@ func update(delta: float) -> void:
|
|||
pass
|
||||
func physics_update(delta: float) -> void:
|
||||
pass
|
||||
func state_input(event: InputEvent) -> void:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -25,3 +25,10 @@ func _process(_delta: float) -> void:
|
|||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
pass
|
||||
|
||||
func _input(_event: InputEvent) -> void:
|
||||
pass
|
||||
|
||||
func state_input(event: InputEvent) -> void:
|
||||
if current_state != null:
|
||||
current_state.state_input(event)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ func enter() -> void:
|
|||
func exit() -> void:
|
||||
pass
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
func state_input(event: InputEvent) -> void:
|
||||
if not machine.is_multiplayer_authority(): return
|
||||
|
||||
if event.is_action_pressed("plr_reload"):
|
||||
|
|
|
|||
|
|
@ -84,6 +84,9 @@ func _physics_process(delta: float) -> void:
|
|||
func _input(event: InputEvent) -> void:
|
||||
if is_multiplayer_authority() == false: return
|
||||
|
||||
if current_state != null:
|
||||
current_state.state_input(event)
|
||||
|
||||
if event.is_action_pressed("plr_ult"):
|
||||
switch("ultimate")
|
||||
elif event.is_action_pressed("plr_bomb"):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue