Created
November 12, 2020 06:23
-
-
Save skeltonmod/c1ca078ec7a5e00a40460669ef9da2c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var y_velocity = velocity.y | |
var dir: Vector3 = Vector3() | |
if x_input != 0: | |
dir += camera.global_transform.basis.x * x_input | |
if y_input != 0: | |
dir += camera.global_transform.basis.z * y_input | |
getdirection(dir) | |
if not is_on_floor(): | |
y_velocity += gravity | |
dir = dir.normalized() * acceleration | |
velocity += dir | |
if velocity.length() > friction: | |
velocity = lerp(velocity,Vector3.ZERO, friction) | |
else: | |
velocity = Vector3.ZERO | |
print(velocity) | |
velocity.y = y_velocity + gravity | |
if velocity.length() > speed: | |
velocity = velocity.normalized() * speed | |
velocity = move_and_slide(velocity,Vector3.UP) | |
if is_on_floor() or is_on_ceiling(): | |
y_velocity = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment