if my character is moving and i click dash it wont dash for some reason can someone please help with this?
the code:
extends CharacterBody2D
var isLeft = false
var Dashing = false
const SPEED = 600.0
const JUMP_VELOCITY = -700.0
const SprintMultiplier = 2
var doubleJump = true
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * 2 * delta
if is_on_floor():
doubleJump = true
# Handle jump.
if Input.is_action_just_pressed("jump"):
if is_on_floor():
velocity.y = JUMP_VELOCITY
if not is_on_floor() and doubleJump:
velocity.y = JUMP_VELOCITY
doubleJump = false
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction = Input.get_axis("left", "right")
var sprint = Input.is_action_pressed("sprint")
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
if direction and sprint:
velocity.x = direction * SPEED * SprintMultiplier
move_and_slide()
if velocity.x > 0:
isLeft = false
elif velocity.x < 0:
isLeft = true
if Input.is_action_just_pressed("Dash") and not Dashing:
Dash()
to each of the statements i just added to the if statements to start movement “and not Dashing” which states that the player is dashing if true it still doesnt work
var isLeft = false
var Dashing = false
const SPEED = 600.0
const JUMP_VELOCITY = -700.0
const SprintMultiplier = 2
var doubleJump = true
func _physics_process(delta):
Add the gravity.
if not is_on_floor():
velocity += get_gravity() * 2 * delta
if is_on_floor():
doubleJump = true
Handle jump.
if Input.is_action_just_pressed(“jump”):
if is_on_floor():
velocity.y = JUMP_VELOCITY
if not is_on_floor() and doubleJump:
velocity.y = JUMP_VELOCITY
doubleJump = false
Get the input direction and handle the movement/deceleration.
As good practice, you should replace UI actions with custom gameplay actions.
var direction = Input.get_axis(“left”, “right”)
var sprint = Input.is_action_pressed(“sprint”)
if direction and not Dashing:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
if direction and sprint and not Dashing:
velocity.x = direction * SPEED * SprintMultiplier
move_and_slide()
var isLeft = false
var Dashing = false
const SPEED = 600.0
const JUMP_VELOCITY = -700.0
const SprintMultiplier = 2
var doubleJump = true
func _ready():
ExtraVariables.Player = self
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * 2 * delta
if is_on_floor():
doubleJump = true
# Handle jump.
if Input.is_action_just_pressed("jump"):
if is_on_floor():
velocity.y = JUMP_VELOCITY
if not is_on_floor() and doubleJump:
velocity.y = JUMP_VELOCITY
doubleJump = false
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction = Input.get_axis("left", "right")
var sprint = Input.is_action_pressed("sprint")
if direction and not Dashing:
velocity.x = direction * SPEED
else:
if not Dashing:
velocity.x = move_toward(velocity.x, 0, SPEED)
if direction and sprint and not Dashing:
velocity.x = direction * SPEED * SprintMultiplier
move_and_slide()
if velocity.x > 0:
isLeft = false
elif velocity.x < 0:
isLeft = true
if Input.is_action_just_pressed("Dash") and not Dashing:
Dash()