ggj2020

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

commit 71a6a5f9cd135488b9fe829f3455b639bd372c49
parent 92722f404387149c8645f3d4afeb64af00b45d4f
Author: Christopher Ray Langford <chris@hellocld.com>
Date:   Fri, 31 Jan 2020 22:25:33 -0500

Movement of player in simple scene works

You can use the left stick to turn in 10 degree increments and the right
stick to move forward/backward/strafe.

Diffstat:
AARVROrigin.gd | 32++++++++++++++++++++++++++++++++
ASpatial.gd | 9+++++++++
ASpatial.tscn | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdefault_env.tres | 2++
4 files changed, 111 insertions(+), 0 deletions(-)

diff --git a/ARVROrigin.gd b/ARVROrigin.gd @@ -0,0 +1,32 @@ +extends ARVROrigin +export var _speed: int = 10 + +var _can_turn = true +var _rotation: float + + +func _process(delta): + var r_stick = Vector2($"ARVRRightController".get_joystick_axis(0), + $"ARVRRightController".get_joystick_axis(1)) + + var cam_basis = $"ARVRCamera".transform.basis + var turn = $"ARVRLeftController".get_joystick_axis(0) + + if abs(turn) > 0.5 && _can_turn: + _can_turn = false + if turn > 0: + _rotation = 10 + else: + _rotation = -10 + rotate(Vector3.UP, deg2rad(_rotation)) + cam_basis = cam_basis.rotated(Vector3.UP, _rotation) + if !_can_turn && abs(turn) < 0.5: + _can_turn = true + + + cam_basis.x.y = 0 + cam_basis.z.y = 0 + + translate(r_stick.x * cam_basis.x.normalized() * delta * _speed) + translate(-r_stick.y * cam_basis.z.normalized() * delta * _speed) + diff --git a/Spatial.gd b/Spatial.gd @@ -0,0 +1,9 @@ +extends Spatial + + +func _ready(): + var VR = ARVRServer.find_interface("OpenVR") + if VR and VR.initialize(): + get_viewport().arvr = true + OS.vsync_enabled = false + Engine.target_fps = 90 diff --git a/Spatial.tscn b/Spatial.tscn @@ -0,0 +1,68 @@ +[gd_scene load_steps=8 format=2] + +[ext_resource path="res://Spatial.gd" type="Script" id=1] +[ext_resource path="res://ARVROrigin.gd" type="Script" id=2] + +[sub_resource type="PrismMesh" id=3] +size = Vector3( 0.25, 0.25, 0.25 ) + +[sub_resource type="GDScript" id=7] +script/source = "extends ARVRController + +# Joystick axis +# 0 - Touchpad/Joystick X +# 1 - Touchpad/Joystick Y +# 2 - Analog Trigger +# 3 - Nothing? + +# Buttons +# + +" + +[sub_resource type="PlaneMesh" id=1] +size = Vector2( 50, 50 ) + +[sub_resource type="SpatialMaterial" id=6] +albedo_color = Color( 0.247059, 0.705882, 0.352941, 1 ) + +[sub_resource type="PrismMesh" id=2] + +[node name="Spatial" type="Spatial"] +script = ExtResource( 1 ) + +[node name="ARVROrigin" type="ARVROrigin" parent="."] +script = ExtResource( 2 ) + +[node name="ARVRCamera" type="ARVRCamera" parent="ARVROrigin"] + +[node name="ARVRLeftController" type="ARVRController" parent="ARVROrigin"] + +[node name="MeshInstance" type="MeshInstance" parent="ARVROrigin/ARVRLeftController"] +transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0 ) +mesh = SubResource( 3 ) +material/0 = null + +[node name="ARVRRightController" type="ARVRController" parent="ARVROrigin"] +controller_id = 2 +script = SubResource( 7 ) + +[node name="MeshInstance2" type="MeshInstance" parent="ARVROrigin/ARVRRightController"] +transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0 ) +mesh = SubResource( 3 ) +material/0 = null + +[node name="PlayerPos" type="Spatial" parent="ARVROrigin"] + +[node name="Floor" type="MeshInstance" parent="."] +mesh = SubResource( 1 ) +material/0 = SubResource( 6 ) + +[node name="MeshInstance" type="MeshInstance" parent="."] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -4 ) +mesh = SubResource( 2 ) +material/0 = null + +[node name="DirectionalLight" type="DirectionalLight" parent="."] +transform = Transform( 0.472826, -0.280103, 0.835451, -0.320795, 0.828346, 0.459275, -0.820686, -0.485166, 0.301808, 0, 0, 0 ) +shadow_enabled = true diff --git a/default_env.tres b/default_env.tres @@ -1,5 +1,7 @@ [gd_resource type="Environment" load_steps=2 format=2] + [sub_resource type="ProceduralSky" id=1] + [resource] background_mode = 2 background_sky = SubResource( 1 )