Removed all instances of velocity being defined for CharacterBody2D (#6862)

* Removed all instances of velocity being defined for `CharacterBody2D`
This commit is contained in:
Emily
2023-03-03 08:07:15 +01:00
committed by GitHub
parent d626c1aa89
commit 3585c66213
3 changed files with 7 additions and 23 deletions
+2 -6
View File
@@ -439,8 +439,6 @@ the ground (including slopes) and jump when standing on the ground:
var jump_speed = -1000
var gravity = 2500
var velocity = Vector2()
func get_input():
velocity.x = 0
var right = Input.is_action_pressed('ui_right')
@@ -457,7 +455,7 @@ the ground (including slopes) and jump when standing on the ground:
func _physics_process(delta):
velocity.y += gravity * delta
get_input()
velocity = move_and_slide(velocity, Vector2(0, -1))
move_and_slide()
.. code-tab:: csharp
@@ -469,8 +467,6 @@ the ground (including slopes) and jump when standing on the ground:
private float _jumpSpeed = -1000;
private float _gravity = 2500;
private Vector2 _velocity = new Vector2();
private void GetInput()
{
_velocity.x = 0;
@@ -491,7 +487,7 @@ the ground (including slopes) and jump when standing on the ground:
{
_velocity.y += _gravity * delta;
GetInput();
_velocity = MoveAndSlide(_velocity, new Vector2(0,-1));
MoveAndSlide();
}
}