pushable in large
This commit is contained in:
parent
e1f2423761
commit
3c1309de47
4 changed files with 25 additions and 6 deletions
|
@ -4,6 +4,7 @@ extends CharacterBody2D
|
|||
@export var gravity = 50
|
||||
var jump_count = 1
|
||||
@export var jump_strength = 100
|
||||
@export var jump_strength_max = 300
|
||||
var is_touching_floor : bool = true
|
||||
var jump_buffer_timer : float
|
||||
var coyote_timer : float = 0.2 # 200 millisecond buffer
|
||||
|
@ -58,12 +59,19 @@ func _physics_process(delta):
|
|||
if(get_slide_collision_count() > 0):
|
||||
for i in get_slide_collision_count():
|
||||
var box = get_slide_collision(i).get_collider() as Box
|
||||
if box and velocity.y >= 0:
|
||||
box.velocity.x = velocity.x*0.8
|
||||
if scale.x == 2:
|
||||
if box and velocity.y >= 0:
|
||||
box.velocity.x = velocity.x*0.8
|
||||
else:
|
||||
if box and velocity.y >= 0 and box.scale.x < 2:
|
||||
box.velocity.x = velocity.x*0.8
|
||||
# print(jump_count) # Uncomment for debugging
|
||||
|
||||
func Jump():
|
||||
velocity.y = -1 * jump_strength
|
||||
if scale.x == 1:
|
||||
velocity.y = -1 * jump_strength
|
||||
elif scale.x == 2:
|
||||
velocity.y = -1 * jump_strength_max
|
||||
jump_count = 0
|
||||
is_touching_floor = false
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue