Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody
- const MAX_SLOPE_ANGLE = 30 #this does anything?
- var deadzone = 0.5
- var speed = 1000
- var direction = Vector3()
- var gravity = -20
- var velocity = Vector3()
- var jumping = false
- #enum state{
- # walk, jump, crouch, dash, ball
- #}#state ; what is this?
- func _ready():
- # Called every time the node is added to the scene.
- # Initialization here
- pass
- func _process(delta):
- direction = Vector3(0, 0, 0)
- #var dir = Vector3() # Where does the player intend to walk to
- var cam_xform = get_node("Camera").get_global_transform()
- if (Input.is_action_pressed("analog_up")):
- direction += cam_xform.basis[1]
- if (Input.is_action_pressed("analog_down")):
- direction += -cam_xform.basis[1]
- if (Input.is_action_pressed("analog_left")):
- direction += -cam_xform.basis[0]
- if (Input.is_action_pressed("analog_right")):
- direction += cam_xform.basis[0]
- #if Input.is_action_pressed("ui_left"):
- # direction.x -= 1
- #if Input.is_action_pressed("ui_right"):
- # direction.x += 1
- #if Input.is_action_pressed("ui_up"):
- # direction.z -= 1
- #if Input.is_action_pressed("ui_down"):
- # direction.z += 1
- ###### old movement
- #direction.y = 0
- direction = direction.normalized()
- direction = direction * speed * delta
- #if velocity.y > 0:
- # gravity = -14
- #else:
- # gravity = -12
- velocity.y += gravity * delta
- velocity.x = direction.x
- velocity.z = direction.z
- velocity = move_and_slide(velocity, Vector3(0, 1, 0))
- #if (state == jump and velocity.y < 0):
- # state = walk
- # pass
- #if (is_on_floor() or is_on_wall()) and Input.is_action_pressed("ui_accept"):
- # velocity.y = 8
- # pass
- var jump = Input.is_action_pressed("ui_accept")
- get_node("Camera/root/Text").text = str(jump)
- get_node("Camera/root/Height").text = str(self.get_global_transform())
- get_node("Camera/root/Joystick").text = str(Input.get_joy_axis(0,0), " ", Input.get_joy_axis(0,1))
- if((jump && !jumping) && (is_on_floor() or is_on_wall())):
- gravity = -10
- velocity.y = 10
- jumping = true
- if(!jump && jumping):
- gravity = -20
- jumping = false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement