ggj2020

My game project for Global Game Jam 2020!
git clone git://git.hellocld.com/ggj2020
Log | Files | Refs

ARVROrigin.gd (834B)


      1 extends ARVROrigin
      2 export var _speed: int = 10
      3 
      4 var _can_turn = true
      5 var _rotation: float
      6 var _rot_increment: int = 30
      7 
      8 func _physics_process(delta):
      9 	var r_stick = Vector2($"RightController".get_joystick_axis(0), 
     10 			$"RightController".get_joystick_axis(1))
     11 	
     12 	var cam_basis = ARVRServer.get_hmd_transform().basis
     13 	var turn = $"LeftController".get_joystick_axis(0)
     14 	
     15 	if abs(turn) > 0.5 && _can_turn:
     16 		_can_turn = false
     17 		if turn > 0:
     18 			_rotation = -_rot_increment
     19 		else:
     20 			 _rotation = _rot_increment
     21 		rotate(Vector3.UP, deg2rad(_rotation))
     22 		cam_basis = cam_basis.rotated(Vector3.UP, _rotation)
     23 	if !_can_turn && abs(turn) < 0.5:
     24 		_can_turn = true
     25 	
     26 	
     27 	cam_basis.x.y = 0
     28 	cam_basis.z.y = 0
     29 	
     30 	translate(r_stick.x * cam_basis.x.normalized() * delta * _speed)
     31 	translate(-r_stick.y * cam_basis.z.normalized() * delta * _speed)