Skip to content
Snippets Groups Projects
Commit 579146a2 authored by STAVRIDIS ADONIS's avatar STAVRIDIS ADONIS 💬
Browse files

#116 fix unresponsive jump

parent acab209d
No related merge requests found
......@@ -2,7 +2,6 @@ extends Node
# Movements
var movementInput:int = 0
var jumpInput:bool = false # Know if the player wants to jump
var jumpId:int = 0 # Distinguish 2 different jumps
var mouseX:int = 0 # Mouse X percentage
var mouseY:int = 0 # Mouse Y percentage
......@@ -31,10 +30,6 @@ func getPlayerInput():
if Input.is_action_just_pressed("movementJump"):
jumpId += 1
if Input.is_action_pressed("movementJump"):
jumpInput = true
else:
jumpInput = false
if Input.is_action_pressed("primaryAttack"):
attackStateInput = PUNCH
......@@ -46,7 +41,7 @@ func getPlayerInput():
mouseY = int(mousePosition.y/vpSize.y * 100) - 50
# Sent without safety resend
rpc_unreliable_id(1, "sendPlayerInputs", movementInput, jumpInput, jumpId,
rpc_unreliable_id(1, "sendPlayerInputs", movementInput, jumpId,
attackStateInput, mouseX, mouseY)
......
......@@ -3,7 +3,7 @@ extends "res://entities/characters/player.gd"
# Called when the node enters the scene tree for the first time.
func _ready():
# Modification for this character
maxJump = 3
maxJump = 2
# Called every frame. 'delta' is the elapsed time since the previous frame.
......
......@@ -126,21 +126,17 @@ func _physics_process(delta:float):
# Called from the game script to update the vars
func getPlayerInputs(movementInput:int, jumpInput:bool, jumpId:int,
attackTypeInput:int, mouseX:int, mouseY:int):
motion = 0
func getPlayerInputs(movementInput:int, jumpId:int, attackTypeInput:int, mouseX:int, mouseY:int):
# Prevent the player from moving when attacking
if isAttacking:
return
motion = movementInput
isJumping = false
# Differentiate a new jump from a reemitted one
if lastJumpId != jumpId:
lastJumpId = jumpId
if jumpInput:
isJumping = true
isJumping = true
# Execute attack
if attackTypeInput != NONE:
......@@ -192,13 +188,13 @@ func processMovement(delta:float):
currentJump = 0
# Reset the last striker
lastStrikerId = ownId
elif currentJump == 0 && !isJumping:
# Initial jump prevented
currentJump = 1
# Jump attempts computation
if isJumping:
isJumping = false
if currentJump < maxJump:
broadcastAnimation(ANIM_JUMP)
currentJump += 1
......
extends Node
master func sendPlayerInputs(movementInput:int, jumpInput:bool, jumpId:int,
attackStateInput:int, mouseX:int, mouseY:int):
master func sendPlayerInputs(movementInput:int, jumpId:int, attackStateInput:int, mouseX:int, mouseY:int):
# Get the input from a client and send it to the matching remote player
var senderId:int = get_tree().get_rpc_sender_id()
if gamestate.players.has(senderId):
gamestate.get_node("/root/game/"+str(senderId)).getPlayerInputs(movementInput,
jumpInput, jumpId, attackStateInput, mouseX, mouseY)
jumpId, attackStateInput, mouseX, mouseY)
# When the player exits the game area
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment