diff --git a/client/levels/test/game.gd b/client/levels/test/game.gd index 08680e37e70bd30e3b2c5bfc31a7243f63cb1e6a..22df655c47eeae36399f4b40f2ce9746fe38a280 100644 --- a/client/levels/test/game.gd +++ b/client/levels/test/game.gd @@ -44,7 +44,8 @@ func getPlayerInput(): # Sent without safety resend rpc_unreliable_id(1, "sendPlayerInputs", movementInput, jumpInput, jumpId, sprintInput, attackStateInput) - + + puppet func backToLobby(): #get_node("/root/lobby").show() get_tree().quit() diff --git a/server/entities/characters/player.gd b/server/entities/characters/player.gd index a87dfd2b9beb688870c25bad4bf85c99f70af168..e514a60fb99d5ff5c3590df9c0f35dc792dbd551 100644 --- a/server/entities/characters/player.gd +++ b/server/entities/characters/player.gd @@ -5,6 +5,7 @@ onready var ownId:int = int(self.name) ######## MOVEMENT AND POSITION VARS ######## onready var collisionShape:CollisionShape = $collisionShape +var bodyRotation:int = 1 # Speed values const MAX_SPEED:float = 8.0 @@ -95,8 +96,10 @@ func getPlayerInputs(movementInput, jumpInput, jumpId, sprintInput, attackTypeIn func processMovement(delta): # Set the side faced by the character if motion > 0: + bodyRotation = 1 set_rotation_degrees(Vector3(0, 0, 0)) elif motion < 0: + bodyRotation = -1 set_rotation_degrees(Vector3(0, 180, 0)) if self.is_on_floor(): @@ -142,6 +145,11 @@ func processMovement(delta): # Update the velocity after the collisions (physical engine ftw) vel = self.move_and_slide(vel, FLOOR_NORMAL) + +# if get_slide_count() > 0: +# var collision = get_slide_collision(0) +# if collision != null: +# vel = vel.bounce(collision.normal) # Send the position of the player @@ -195,8 +203,9 @@ func secondaryAttack(): # Called when detected by an attack's hitbox -func hurt(damages:int, sourceId:int): +func hurt(damages:int, sourceId:int, force:Vector3): hp += damages + vel += Vector3(force.x*hp,force.y,force.z) lastStrikerId = sourceId rpc_unreliable_id(ownId, "hurt", hp) @@ -209,17 +218,19 @@ func die(): # Primary hit has landed on something func _on_primaryHitArea_body_entered(body): + var force = Vector3(bodyRotation, 8, 0) if int(body.name)==ownId: return print("body named " + body.name + " hit: primary") - body.hurt(primaryAttackDmg, ownId) + body.hurt(primaryAttackDmg, ownId, force) # Secondary hit has landed on something func _on_secondaryHitArea_body_entered(body): + var force = Vector3(bodyRotation, 0, 0) if int(body.name)==ownId: return print("body named " + body.name + " hit: secondary") - body.hurt(secondaryAttackDmg, ownId) + body.hurt(secondaryAttackDmg, ownId, force)