ggj2020

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

commit d38cd5c4f792522c85f36739cdd82b292dde2e8d
parent 5db0c9e7aba34ace603033325e134566fec6e9ae
Author: Christopher Ray Langford <chris@hellocld.com>
Date:   Sat,  1 Feb 2020 14:36:04 -0500

Fixed directional throwing stuff

Not sure why, but the velocity is super high when a slow but long arc is
made with the throwing controller

Diffstat:
MARVROrigin.gd | 1-
MGrabbyHand.gd | 16++++++++++------
MSpatial.tscn | 18+++++++-----------
3 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/ARVROrigin.gd b/ARVROrigin.gd @@ -29,4 +29,3 @@ func _physics_process(delta): translate(r_stick.x * cam_basis.x.normalized() * delta * _speed) translate(-r_stick.y * cam_basis.z.normalized() * delta * _speed) - diff --git a/GrabbyHand.gd b/GrabbyHand.gd @@ -2,8 +2,10 @@ extends ARVRController var _mesh_basis: Basis onready var _velocity_queue = [] -var _queue_size = 60 -onready var _last_pos = transform.origin +export var _queue_size = 60 +export var _throw_force = 30 +onready var _last_pos = global_transform.origin +onready var _last_player_pos = get_parent().transform.origin signal grabbing signal releasing(velocity) @@ -15,8 +17,10 @@ func _ready(): func _physics_process(delta): - _velocity_queue.push_back(transform.origin - _last_pos) - _last_pos = transform.origin + _velocity_queue.push_back((global_transform.origin - _last_pos) - + (get_parent().transform.origin - _last_player_pos)) + _last_pos = global_transform.origin + _last_player_pos = get_parent().transform.origin #use this to neutralize player movement while holding something if _velocity_queue.size() > _queue_size: _velocity_queue.pop_front() @@ -42,5 +46,5 @@ func is_grabbing() -> bool: func _get_velocity() -> Vector3: var vel = Vector3.ZERO for i in range(_velocity_queue.size()): - vel += (_velocity_queue[i] * i) - return vel + vel += (_velocity_queue[i] * (float(i) / _velocity_queue.size())) + return vel * _throw_force diff --git a/Spatial.tscn b/Spatial.tscn @@ -26,15 +26,11 @@ normal_texture = SubResource( 8 ) [sub_resource type="ConcavePolygonShape" id=9] data = PoolVector3Array( 50, 0, 50, -50, 0, 50, 50, 0, -50, -50, 0, 50, -50, 0, -50, 50, 0, -50 ) -[sub_resource type="CylinderShape" id=4] -radius = 0.5 -height = 1.0 +[sub_resource type="BoxShape" id=10] +extents = Vector3( 0.25, 0.25, 0.25 ) -[sub_resource type="CylinderMesh" id=5] -top_radius = 0.5 -bottom_radius = 0.5 -height = 1.0 -radial_segments = 16 +[sub_resource type="CubeMesh" id=11] +size = Vector3( 0.5, 0.5, 0.5 ) [node name="Spatial" type="Spatial"] script = ExtResource( 1 ) @@ -52,14 +48,14 @@ shape = SubResource( 9 ) [node name="Grabbable" type="RigidBody" parent="."] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.88499, 8.72828 ) -mass = 2.04082 +mass = 2.0 script = ExtResource( 3 ) [node name="CollisionShape" type="CollisionShape" parent="Grabbable"] -shape = SubResource( 4 ) +shape = SubResource( 10 ) [node name="Cone" type="MeshInstance" parent="Grabbable"] -mesh = SubResource( 5 ) +mesh = SubResource( 11 ) material/0 = null [node name="DirectionalLight" type="DirectionalLight" parent="."]