Better enemy bouncing
This commit is contained in:
parent
6eace8721c
commit
487bfc87d7
@ -9,11 +9,12 @@ onready var init_boost_type = player_state_machine.init_boost_type
|
|||||||
onready var effect_player = $BlobbyActionEffects/AnimationPlayer
|
onready var effect_player = $BlobbyActionEffects/AnimationPlayer
|
||||||
|
|
||||||
var wall_touch_direction = 1
|
var wall_touch_direction = 1
|
||||||
|
var stomping = false
|
||||||
|
|
||||||
# When the Enemy stomp AREA enters the enemy collision area -> stomp
|
# When the Enemy stomp AREA enters the enemy collision area -> stomp
|
||||||
func _on_BlobbySkin_area_entered(area: Area2D) -> void:
|
func _on_BlobbySkin_area_entered(area: Area2D) -> void:
|
||||||
if area.is_in_group("weakpoint"):
|
if area.is_in_group("weakpoint"):
|
||||||
velocity = calculate_stomp_velocity(velocity, stomp_feedback)
|
stomping = true
|
||||||
if area.is_in_group("harmful"):
|
if area.is_in_group("harmful"):
|
||||||
die()
|
die()
|
||||||
|
|
||||||
@ -227,6 +228,9 @@ func calculate_jump_velocity(
|
|||||||
) -> Vector2:
|
) -> Vector2:
|
||||||
var state = player_state_machine.state
|
var state = player_state_machine.state
|
||||||
var additive_jump_force = velocity_jump_boost_ratio * abs(velocity.x) * mass
|
var additive_jump_force = velocity_jump_boost_ratio * abs(velocity.x) * mass
|
||||||
|
if stomping:
|
||||||
|
additive_jump_force += stomp_feedback / delta
|
||||||
|
stomping = false
|
||||||
|
|
||||||
if state != "jump":
|
if state != "jump":
|
||||||
linear_velocity.y = PhysicsFunc.two_step_euler(
|
linear_velocity.y = PhysicsFunc.two_step_euler(
|
||||||
@ -276,6 +280,8 @@ func calculate_fall_velocity(
|
|||||||
jump_buffer_filled = true
|
jump_buffer_filled = true
|
||||||
if is_correct_airstrafe_input():
|
if is_correct_airstrafe_input():
|
||||||
linear_velocity = execute_airstrafe(linear_velocity, delta, direction)
|
linear_velocity = execute_airstrafe(linear_velocity, delta, direction)
|
||||||
|
if stomping:
|
||||||
|
linear_velocity = calculate_jump_velocity(Vector2(linear_velocity.x,0), delta, direction)
|
||||||
return linear_velocity
|
return linear_velocity
|
||||||
|
|
||||||
|
|
||||||
@ -329,14 +335,6 @@ func execute_airstrafe(
|
|||||||
return linear_velocity
|
return linear_velocity
|
||||||
|
|
||||||
|
|
||||||
func calculate_stomp_velocity(
|
|
||||||
linear_velocity: Vector2, impulse: float
|
|
||||||
) -> Vector2:
|
|
||||||
var out := linear_velocity
|
|
||||||
out.y = -impulse
|
|
||||||
return out
|
|
||||||
|
|
||||||
|
|
||||||
func execute_movement() -> void:
|
func execute_movement() -> void:
|
||||||
velocity = move_and_slide(velocity, FLOOR_NORMAL,false, 4, 0.785398,false)
|
velocity = move_and_slide(velocity, FLOOR_NORMAL,false, 4, 0.785398,false)
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ const PhysicsConst = preload("res://src/Utilities/Physic/PhysicsConst.gd")
|
|||||||
|
|
||||||
const FLOOR_NORMAL := Vector2.UP
|
const FLOOR_NORMAL := Vector2.UP
|
||||||
|
|
||||||
var stomp_feedback := 1000.0
|
var stomp_feedback := 1200
|
||||||
var inair_velocity := 21
|
var inair_velocity := 21
|
||||||
var wallslide_threshold := 1000
|
var wallslide_threshold := 1000
|
||||||
var base_floor_friction := 0.5
|
var base_floor_friction := 0.5
|
||||||
@ -21,6 +21,8 @@ var init_acceleration_force := {
|
|||||||
# newtonmeters is the unit
|
# newtonmeters is the unit
|
||||||
var acceleration_force := {
|
var acceleration_force := {
|
||||||
"walk": Vector2(1800, 1233),
|
"walk": Vector2(1800, 1233),
|
||||||
|
"fall": Vector2(0, 0),
|
||||||
|
"jump": Vector2(0, 0),
|
||||||
"idle": Vector2(1800, 1233),
|
"idle": Vector2(1800, 1233),
|
||||||
"duck": Vector2(500, 1400),
|
"duck": Vector2(500, 1400),
|
||||||
"run": Vector2(2500, 1290),
|
"run": Vector2(2500, 1290),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user