More player movement code
parent
7cfa56d974
commit
d911a68556
16
Player.gd
16
Player.gd
|
@ -4,19 +4,27 @@ const GRAVITY = 9.8
|
||||||
|
|
||||||
var velocity = Vector3.ZERO
|
var velocity = Vector3.ZERO
|
||||||
|
|
||||||
|
var walkDirection = Vector2.ZERO
|
||||||
|
|
||||||
# Declare member variables here. Examples:
|
# Declare member variables here. Examples:
|
||||||
# var a = 2
|
# var a = 2
|
||||||
# var b = "text"
|
# var b = "text"
|
||||||
|
|
||||||
func gravity(delta):
|
func gravity():
|
||||||
self.velocity.y -= GRAVITY * delta
|
self.velocity.y -= GRAVITY
|
||||||
|
|
||||||
|
func walk():
|
||||||
|
walkDirection = Vector2.ZERO
|
||||||
|
|
||||||
|
#if input
|
||||||
|
|
||||||
func motion(delta):
|
func motion(delta):
|
||||||
self.move_and_slide(velocity, Vector3.UP)
|
self.move_and_slide(velocity * delta, Vector3.UP)
|
||||||
#rpc("move_and_slide", velocity, Vector3.UP)
|
#rpc("move_and_slide", velocity, Vector3.UP)
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
gravity(delta)
|
gravity()
|
||||||
|
walk()
|
||||||
motion(delta)
|
motion(delta)
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue