@export var dash_speed: float = 900.0 @export var dash_time: float = 0.15 @export var dash_cooldown: float = 0.5 @export var allow_air_dash: bool = true
var is_dashing: bool = false var can_dash: bool = true var dash_timer: float = 0.0 var cooldown_timer: float = 0.0 var dash_dir: Vector2 = Vector2.ZERO var stored_velocity: Vector2 = Vector2.ZERO
func _physics_process(delta): # أثناء الداش if is_dashing: dash_timer -= delta velocity = dash_dir * dash_speed move_and_slide() if dash_timer <= 0.0: end_dash() return
# مؤقت الكولداون if not can_dash: cooldown_timer -= delta if cooldown_timer <= 0.0: can_dash = true
# لما يضغط زر الداش if Input.is_action_just_pressed("dash") and can_dash: if is_on_floor() or allow_air_dash: start_dash()
# تحديد اتجاه الداش var input_dir = Vector2( Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left"), Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up") )
if input_dir == Vector2.ZERO: # لو ما ضغط أي اتجاه، داش حسب الاتجاه الحالي if velocity.x != 0: dash_dir = Vector2(sign(velocity.x), 0) else: dash_dir = Vector2.RIGHT else: dash_dir = input_dir.normalized()
@export var dash_speed: float = 900.0 @export var dash_time: float = 0.15 @export var dash_cooldown: float = 0.5 @export var allow_air_dash: bool = true
var is_dashing: bool = false var can_dash: bool = true var dash_timer: float = 0.0 var cooldown_timer: float = 0.0 var dash_dir: Vector2 = Vector2.ZERO var stored_velocity: Vector2 = Vector2.ZERO
func _physics_process(delta): # أثناء الداش if is_dashing: dash_timer -= delta velocity = dash_dir * dash_speed
@export var dash_speed: float = 900.0 @export var dash_time: float = 0.15 @export var dash_cooldown: float = 0.5 @export var allow_air_dash: bool = true
var is_dashing: bool = false var can_dash: bool = true var dash_timer: float = 0.0 var cooldown_timer: float = 0.0 var dash_dir: Vector2 = Vector2.ZERO var stored_velocity: Vector2 = Vector2.ZERO
func _physics_process(delta): # لو في داش شغال if is_dashing: dash_timer -= delta velocity = dash_dir * dash_speed move_and_slide() if dash_timer <= 0: end_dash() return
# كولداون للداش if not can_dash: cooldown_timer -= delta if cooldown_timer <= 0: can_dash = true
# لما يضغط زر الداش if Input.is_action_just_pressed("dash") and can_dash: if is_on_floor() or allow_air_dash: start_dash()
# تحديد الاتجاه (يمين أو يسار) var input_dir = Vector2( Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left"), Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up") )
if input_dir == Vector2.ZERO: # لو اللاعب ما ضغط أي اتجاه، داش بنفس الاتجاه الحالي dash_dir = Vector2(sign(velocity.x), 0) if dash_dir == Vector2.ZERO: dash_dir = Vector2.RIGHT else: dash_dir = input_dir.normalized()
abdulnor_13
extends CharacterBody2D
@export var dash_speed: float = 900.0
@export var dash_time: float = 0.15
@export var dash_cooldown: float = 0.5
@export var allow_air_dash: bool = true
var is_dashing: bool = false
var can_dash: bool = true
var dash_timer: float = 0.0
var cooldown_timer: float = 0.0
var dash_dir: Vector2 = Vector2.ZERO
var stored_velocity: Vector2 = Vector2.ZERO
func _physics_process(delta):
# أثناء الداش
if is_dashing:
dash_timer -= delta
velocity = dash_dir * dash_speed
move_and_slide()
if dash_timer <= 0.0:
end_dash()
return
# مؤقت الكولداون
if not can_dash:
cooldown_timer -= delta
if cooldown_timer <= 0.0:
can_dash = true
# لما يضغط زر الداش
if Input.is_action_just_pressed("dash") and can_dash:
if is_on_floor() or allow_air_dash:
start_dash()
func start_dash():
is_dashing = true
can_dash = false
dash_timer = dash_time
cooldown_timer = dash_cooldown
stored_velocity = velocity
# تحديد اتجاه الداش
var input_dir = Vector2(
Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left"),
Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
)
if input_dir == Vector2.ZERO:
# لو ما ضغط أي اتجاه، داش حسب الاتجاه الحالي
if velocity.x != 0:
dash_dir = Vector2(sign(velocity.x), 0)
else:
dash_dir = Vector2.RIGHT
else:
dash_dir = input_dir.normalized()
velocity = dash_dir * dash_speed
func end_dash():
is_dashing = false
velocity = stored_velocity
1 week ago | [YT] | 0
View 0 replies
abdulnor_13
extends CharacterBody2D
@export var dash_speed: float = 900.0
@export var dash_time: float = 0.15
@export var dash_cooldown: float = 0.5
@export var allow_air_dash: bool = true
var is_dashing: bool = false
var can_dash: bool = true
var dash_timer: float = 0.0
var cooldown_timer: float = 0.0
var dash_dir: Vector2 = Vector2.ZERO
var stored_velocity: Vector2 = Vector2.ZERO
func _physics_process(delta):
# أثناء الداش
if is_dashing:
dash_timer -= delta
velocity = dash_dir * dash_speed
1 week ago | [YT] | 0
View 0 replies
abdulnor_13
# هذا المقطع تضيفه في سكربت اللاعب
@export var dash_speed: float = 900.0
@export var dash_time: float = 0.15
@export var dash_cooldown: float = 0.5
@export var allow_air_dash: bool = true
var is_dashing: bool = false
var can_dash: bool = true
var dash_timer: float = 0.0
var cooldown_timer: float = 0.0
var dash_dir: Vector2 = Vector2.ZERO
var stored_velocity: Vector2 = Vector2.ZERO
func _physics_process(delta):
# لو في داش شغال
if is_dashing:
dash_timer -= delta
velocity = dash_dir * dash_speed
move_and_slide()
if dash_timer <= 0:
end_dash()
return
# كولداون للداش
if not can_dash:
cooldown_timer -= delta
if cooldown_timer <= 0:
can_dash = true
# لما يضغط زر الداش
if Input.is_action_just_pressed("dash") and can_dash:
if is_on_floor() or allow_air_dash:
start_dash()
func start_dash():
is_dashing = true
can_dash = false
dash_timer = dash_time
cooldown_timer = dash_cooldown
stored_velocity = velocity
# تحديد الاتجاه (يمين أو يسار)
var input_dir = Vector2(
Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left"),
Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
)
if input_dir == Vector2.ZERO:
# لو اللاعب ما ضغط أي اتجاه، داش بنفس الاتجاه الحالي
dash_dir = Vector2(sign(velocity.x), 0)
if dash_dir == Vector2.ZERO:
dash_dir = Vector2.RIGHT
else:
dash_dir = input_dir.normalized()
velocity = dash_dir * dash_speed
func end_dash():
is_dashing = false
velocity = stored_velocity
1 week ago | [YT] | 0
View 0 replies