Adjusted velocity calculation without acceleration.
This commit is contained in:
parent
75d963d2a5
commit
e5eea103ab
2 changed files with 12 additions and 11 deletions
|
|
@ -34,18 +34,19 @@ func _process(delta):
|
||||||
position = position.clamp(Vector2(12,12), screensize - Vector2(12,12))
|
position = position.clamp(Vector2(12,12), screensize - Vector2(12,12))
|
||||||
|
|
||||||
# Update velocity based on input
|
# Update velocity based on input
|
||||||
var direction = Vector2.ZERO
|
#var direction = Vector2.ZERO
|
||||||
if Input.is_action_pressed("down"):
|
#if Input.is_action_pressed("down"):
|
||||||
direction.y += 1
|
#direction.y += 1
|
||||||
if Input.is_action_pressed("up"):
|
#if Input.is_action_pressed("up"):
|
||||||
direction.y -= 1
|
#direction.y -= 1
|
||||||
|
#
|
||||||
# Normalize direction and apply speed
|
## Normalize direction and apply speed
|
||||||
if direction.length() > 0:
|
#if direction.length() > 0:
|
||||||
velocity = direction.normalized() * speed
|
#velocity = direction.normalized() * speed
|
||||||
|
|
||||||
# Update velocity
|
# Update velocity
|
||||||
velocity += velocity * delta
|
#velocity += velocity * delta
|
||||||
|
velocity = input * speed
|
||||||
|
|
||||||
|
|
||||||
if Input.is_action_pressed("shoot"):
|
if Input.is_action_pressed("shoot"):
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ extends Area2D
|
||||||
|
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
position += transform.y * (shot_data.speed - player.velocity.y) * delta #This works normally
|
position += transform.y * (shot_data.speed + player.velocity.y) * delta #This works normally
|
||||||
#position += (transform.y + player.velocity) * shot_data.speed * delta #This doesn'tt
|
#position += (transform.y + player.velocity) * shot_data.speed * delta #This doesn'tt
|
||||||
func _on_visible_on_screen_notifier_2d_screen_exited() -> void:
|
func _on_visible_on_screen_notifier_2d_screen_exited() -> void:
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue