From 557320bce288e2ae761cdab91fb673e7865face4 Mon Sep 17 00:00:00 2001 From: dariasteam Date: Tue, 19 Feb 2019 19:16:19 +0000 Subject: [PATCH] Allow movement over vertical walls --- Scenes/Player.gd | 13 +++++++------ Scenes/platform.gd | 6 +++--- abstract_platform.gd | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Scenes/Player.gd b/Scenes/Player.gd index a6d3a0a..8c82ef5 100644 --- a/Scenes/Player.gd +++ b/Scenes/Player.gd @@ -31,7 +31,7 @@ var decal = preload("res://Scenes/decal.tscn") onready var last_safe_rotation = axis.get_rotation().y var platforms_counter = 0 -var rotation_range = Vector2(0,0) +var rotation_range = Vector3(0,0,0) var movement_limited = false export (int) var n_platforms_to_meteorize = 3 @@ -39,11 +39,12 @@ export (int) var n_platforms_to_meteorize = 3 var meteor = false var color -func limit_rotation_range(allowed_range): +# z is the height +func limit_rotation_range(allowed_range): movement_limited = true var first = normalize_rot(allowed_range.x) var second = normalize_rot(allowed_range.y) - rotation_range = Vector2(first, second) + rotation_range = Vector3(first, second, allowed_range.z) func unlimit_rotation_range(): @@ -126,9 +127,9 @@ func is_in_range (v, r_a, r_b): func _on_set_rotation (rot): var intent_rotation = rot + last_safe_rotation var current_rotation = axis.get_rotation_deg().y; - var has_collided = false - - if (movement_limited): + var has_collided = false + + if (movement_limited and ball.get_global_transform().origin.y < rotation_range.z): # check altitude of the ball var local_rotation_range = Vector2(0,0) if (current_rotation >= 0): diff --git a/Scenes/platform.gd b/Scenes/platform.gd index df43176..c01c6e1 100644 --- a/Scenes/platform.gd +++ b/Scenes/platform.gd @@ -25,8 +25,8 @@ func _ready(): aux.set_translation(Vector3(0,rand_range(-0.01, 0.01), 0)) aux.set_material (global.mat_regular) elif (rand == 15 and !cant_move): - var segment_width = offset / 2; - allowed_range = Vector2(rot - offset - segment_width, rot - 2) + var segment_width = offset / 2; + allowed_range = Vector3(rot - offset - segment_width, rot - 2, get_translation().y + get_parent().space) cant_move = true aux = segment_tall.instance() aux.set_material (global.mat_regular) @@ -52,7 +52,7 @@ func _process(delta): rotate(Vector3(0,1,0), velocity * 0.0003) func send_next_platform_limits(): - if (next_platform.allowed_range != Vector2(-1,-1)): + if (next_platform.allowed_range != Vector3(-1,-1,-1)): global.player.limit_rotation_range(next_platform.allowed_range) else: global.player.unlimit_rotation_range() diff --git a/abstract_platform.gd b/abstract_platform.gd index 48a0222..9a275a1 100644 --- a/abstract_platform.gd +++ b/abstract_platform.gd @@ -7,13 +7,13 @@ var segment = preload ("res://Scenes/Regular_Segment.tscn") var next_platform -var allowed_range = Vector2(-1,-1) +var allowed_range = Vector3(-1,-1, -1) const SEGMENTS = 16 onready var offset = float(360) / SEGMENTS func send_next_platform_limits(): - if (next_platform.allowed_range != Vector2(-1,-1)): + if (next_platform.allowed_range != Vector3(-1,-1,-1)): global.player.limit_rotation_range(next_platform.allowed_range) else: global.player.unlimit_rotation_range()