Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.08 KB | None | 0 0
  1. extends KinematicBody
  2.  
  3. const MAX_SLOPE_ANGLE = 30 #this does anything?
  4. var deadzone = 0.5
  5. var speed = 1000
  6. var direction = Vector3()
  7. var gravity = -20
  8. var velocity = Vector3()
  9.  
  10. var jumping = false
  11. #enum state{
  12. #   walk, jump, crouch, dash, ball
  13. #}#state ; what is this?
  14.  
  15. func _ready():
  16.     # Called every time the node is added to the scene.
  17.     # Initialization here
  18.    
  19.     pass
  20.  
  21. func _process(delta):
  22.     direction = Vector3(0, 0, 0)
  23.     #var dir = Vector3() # Where does the player intend to walk to
  24.     var cam_xform = get_node("Camera").get_global_transform()
  25.    
  26.     if (Input.is_action_pressed("analog_up")):
  27.         direction += cam_xform.basis[1]
  28.     if (Input.is_action_pressed("analog_down")):
  29.         direction += -cam_xform.basis[1]
  30.     if (Input.is_action_pressed("analog_left")):
  31.         direction += -cam_xform.basis[0]
  32.     if (Input.is_action_pressed("analog_right")):
  33.         direction += cam_xform.basis[0]
  34.    
  35.     #if Input.is_action_pressed("ui_left"):
  36.     #   direction.x -= 1
  37.     #if Input.is_action_pressed("ui_right"):
  38.     #   direction.x += 1
  39.     #if Input.is_action_pressed("ui_up"):
  40.     #   direction.z -= 1
  41.     #if Input.is_action_pressed("ui_down"):
  42.     #   direction.z += 1
  43.         ###### old movement
  44.    
  45.     #direction.y = 0
  46.     direction = direction.normalized()
  47.     direction = direction * speed * delta
  48.    
  49.     #if velocity.y > 0:
  50.     #   gravity = -14
  51.     #else:
  52.     #   gravity = -12
  53.    
  54.     velocity.y += gravity * delta
  55.     velocity.x = direction.x
  56.     velocity.z = direction.z
  57.    
  58.     velocity = move_and_slide(velocity, Vector3(0, 1, 0))
  59.    
  60.     #if (state == jump and velocity.y < 0):
  61.     #   state = walk
  62.     #   pass
  63.    
  64.     #if (is_on_floor() or is_on_wall()) and Input.is_action_pressed("ui_accept"):
  65.     #   velocity.y = 8 
  66.     #   pass
  67.    
  68.     var jump = Input.is_action_pressed("ui_accept")
  69.     get_node("Camera/root/Text").text = str(jump)
  70.     get_node("Camera/root/Height").text = str(self.get_global_transform())
  71.     get_node("Camera/root/Joystick").text = str(Input.get_joy_axis(0,0), " ", Input.get_joy_axis(0,1))
  72.     if((jump && !jumping) && (is_on_floor() or is_on_wall())):
  73.         gravity = -10
  74.         velocity.y = 10
  75.         jumping = true
  76.     if(!jump && jumping):
  77.         gravity = -20
  78.         jumping = false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement