Teleporter tutorial
This commit is contained in:
1 parent
82d1375871
commit
2c203c8476
7 files changed
+112
-7
No files matched your search
@@ -0,0 +1,44 @@
|
|||||||
|
extends Node2D
|
||||||
|
|
||||||
|
@export var paired_teleporter: String
|
||||||
|
var checked_teleport
|
||||||
|
var telecam_speed_mult = 4
|
||||||
|
var enabled = true
|
||||||
|
var cooldown = 2
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
modulate = Color.PURPLE
|
||||||
|
add_to_group("TELEPORTERS")
|
||||||
|
add_to_group("Hidden")
|
||||||
|
|
||||||
|
func check_for_pair() -> String:
|
||||||
|
print(paired_teleporter)
|
||||||
|
return paired_teleporter
|
||||||
|
|
||||||
|
func disable():
|
||||||
|
enabled = false
|
||||||
|
$Sprite2D.modulate = Color.DARK_ORANGE
|
||||||
|
|
||||||
|
func enable():
|
||||||
|
enabled = true
|
||||||
|
$Sprite2D.modulate = Color.WHITE
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
func _on_contact(body) -> void:
|
||||||
|
#get_tree().call_group("TELEPORTERS","disable")
|
||||||
|
for teleporter in get_tree().get_nodes_in_group("TELEPORTERS"):
|
||||||
|
if teleporter != self:
|
||||||
|
if teleporter.paired_teleporter == paired_teleporter and enabled:
|
||||||
|
%Player2D.get_node("Camera2D").position_smoothing_enabled = false
|
||||||
|
if %Player2D.teleport_cooldown > 0:
|
||||||
|
return
|
||||||
|
body.set_position(teleporter.get_position())
|
||||||
|
%Player2D.on_teleport()
|
||||||
|
disable()
|
||||||
|
await get_tree().create_timer(cooldown).timeout
|
||||||
|
enable()
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://btxx0p5ccar5f
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
[gd_scene format=3 uid="uid://7bjqgxckho"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://btxx0p5ccar5f" path="res://hidden_teleporter.gd" id="1_52wed"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://d0tvtt4eu8jmt" path="res://art/block/portal.png" id="2_rx1y0"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://55ihxa2emnep" path="res://art/block/portal2.png" id="3_5admx"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://d4a5x8gwhl2wc" path="res://art/block/portal3.png" id="4_tfiuq"]
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_tuehi"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("2_rx1y0")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("3_5admx")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("4_tfiuq")
|
||||||
|
}],
|
||||||
|
"loop": 1,
|
||||||
|
"name": &"default",
|
||||||
|
"speed": 5.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_7k7bx"]
|
||||||
|
radius = 9.0
|
||||||
|
|
||||||
|
[node name="HiddenTeleporter" type="Node2D" unique_id=1201409437]
|
||||||
|
script = ExtResource("1_52wed")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="AnimatedSprite2D" parent="." unique_id=395479262]
|
||||||
|
sprite_frames = SubResource("SpriteFrames_tuehi")
|
||||||
|
autoplay = "default"
|
||||||
|
|
||||||
|
[node name="Area2D" type="Area2D" parent="Sprite2D" unique_id=2050186824]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Sprite2D/Area2D" unique_id=1560168165]
|
||||||
|
shape = SubResource("CircleShape2D_7k7bx")
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="Sprite2D/Area2D" to="." method="_on_contact"]
|
||||||
+2
-1
@@ -111,7 +111,8 @@ func on_death(instant = false, player_position = position):
|
|||||||
get_tree().paused = false
|
get_tree().paused = false
|
||||||
|
|
||||||
#position = %LevelStart.position
|
#position = %LevelStart.position
|
||||||
position = spawn_point
|
velocity = Vector2(0,0)
|
||||||
|
position = spawn_point + Vector2(0,-100)
|
||||||
await get_tree().create_timer(0.1).timeout
|
await get_tree().create_timer(0.1).timeout
|
||||||
death_cooldown = 0
|
death_cooldown = 0
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -11,10 +11,10 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://dyxbitw8hbd3s" path="res://art/player/crouch/frame2.png" id="7_lu0ka"]
|
[ext_resource type="Texture2D" uid="uid://dyxbitw8hbd3s" path="res://art/player/crouch/frame2.png" id="7_lu0ka"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bfyd1tro3s0gl" path="res://art/player/crystal2.png" id="7_oy4pt"]
|
[ext_resource type="Texture2D" uid="uid://bfyd1tro3s0gl" path="res://art/player/crystal2.png" id="7_oy4pt"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dh7a1knyqn5nd" path="res://art/player/running/frame3.png" id="7_pmt5n"]
|
[ext_resource type="Texture2D" uid="uid://dh7a1knyqn5nd" path="res://art/player/running/frame3.png" id="7_pmt5n"]
|
||||||
[ext_resource type="Texture2D" uid="uid://lk0f1qyswyxv" path="res://art/player/idle/frame1.png" id="8_3prq1"]
|
[ext_resource type="Texture2D" uid="uid://lk0f1qyswyxv" path="res://art/player/running/frame1.png" id="8_3prq1"]
|
||||||
[ext_resource type="Texture2D" uid="uid://yf13nw31k8ua" path="res://art/player/running/frame4.png" id="8_nj6as"]
|
[ext_resource type="Texture2D" uid="uid://yf13nw31k8ua" path="res://art/player/running/frame4.png" id="8_nj6as"]
|
||||||
[ext_resource type="Texture2D" uid="uid://du5i0tg6u1lal" path="res://art/player/crystal3.png" id="8_ukfft"]
|
[ext_resource type="Texture2D" uid="uid://du5i0tg6u1lal" path="res://art/player/crystal3.png" id="8_ukfft"]
|
||||||
[ext_resource type="Texture2D" uid="uid://lmje8plw76e1" path="res://art/player/idle/frame2.png" id="9_lu0ka"]
|
[ext_resource type="Texture2D" uid="uid://lmje8plw76e1" path="res://art/player/running/frame2.png" id="9_lu0ka"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bko8dvawpul3c" path="res://art/player/crystal4.png" id="9_ur4nw"]
|
[ext_resource type="Texture2D" uid="uid://bko8dvawpul3c" path="res://art/player/crystal4.png" id="9_ur4nw"]
|
||||||
[ext_resource type="Texture2D" uid="uid://m5djssna67e1" path="res://art/player/crouch/frame3.png" id="9_w0gjo"]
|
[ext_resource type="Texture2D" uid="uid://m5djssna67e1" path="res://art/player/crouch/frame3.png" id="9_w0gjo"]
|
||||||
[ext_resource type="Texture2D" uid="uid://ba4kjeulthw1g" path="res://art/hats/dunce1.png" id="10_5s8kx"]
|
[ext_resource type="Texture2D" uid="uid://ba4kjeulthw1g" path="res://art/hats/dunce1.png" id="10_5s8kx"]
|
||||||
@@ -151,7 +151,7 @@ texture = ExtResource("4_nj6as")
|
|||||||
|
|
||||||
[node name="Parallax2D" type="Parallax2D" parent="." unique_id=270393374]
|
[node name="Parallax2D" type="Parallax2D" parent="." unique_id=270393374]
|
||||||
repeat_size = Vector2(1280, 720)
|
repeat_size = Vector2(1280, 720)
|
||||||
autoscroll = Vector2(5, 0)
|
autoscroll = Vector2(1, 0)
|
||||||
follow_viewport = false
|
follow_viewport = false
|
||||||
ignore_camera_scroll = true
|
ignore_camera_scroll = true
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ animations = [{
|
|||||||
}]
|
}]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_7k7bx"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_7k7bx"]
|
||||||
radius = 14.0
|
radius = 9.0
|
||||||
|
|
||||||
[node name="Teleporter" type="Node2D" unique_id=1201409437]
|
[node name="Teleporter" type="Node2D" unique_id=1201409437]
|
||||||
script = ExtResource("1_tuehi")
|
script = ExtResource("1_tuehi")
|
||||||
|
|||||||
+21
-2
@@ -33,7 +33,7 @@ scale = Vector2(1, 1.0155824)
|
|||||||
|
|
||||||
[node name="Player2D" parent="." unique_id=889851478 instance=ExtResource("1_aqk2v")]
|
[node name="Player2D" parent="." unique_id=889851478 instance=ExtResource("1_aqk2v")]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
position = Vector2(-4844.9995, 356.44568)
|
position = Vector2(-4838.9995, 356.4457)
|
||||||
rotation = 0.0005533503
|
rotation = 0.0005533503
|
||||||
safe_margin = 0.08
|
safe_margin = 0.08
|
||||||
|
|
||||||
@@ -479,7 +479,7 @@ scale = Vector2(0.8267815, 0.8267815)
|
|||||||
stretch_mode = 5
|
stretch_mode = 5
|
||||||
|
|
||||||
[node name="Pharaoh" parent="." unique_id=44054531 instance=ExtResource("15_hiqwa")]
|
[node name="Pharaoh" parent="." unique_id=44054531 instance=ExtResource("15_hiqwa")]
|
||||||
position = Vector2(192, 177.23824)
|
position = Vector2(192, 193.97743)
|
||||||
|
|
||||||
[node name="Pharaoh2" parent="." unique_id=1541178727 instance=ExtResource("15_hiqwa")]
|
[node name="Pharaoh2" parent="." unique_id=1541178727 instance=ExtResource("15_hiqwa")]
|
||||||
position = Vector2(6338, -42.34024)
|
position = Vector2(6338, -42.34024)
|
||||||
@@ -646,4 +646,23 @@ position = Vector2(-1351, -14.769848)
|
|||||||
sign_text = "MEDITATING REVEALS SECRETS"
|
sign_text = "MEDITATING REVEALS SECRETS"
|
||||||
text_dismiss_timer = 4
|
text_dismiss_timer = 4
|
||||||
|
|
||||||
|
[node name="Sign10" parent="." unique_id=600787286 instance=ExtResource("24_wjb0r")]
|
||||||
|
position = Vector2(-1349, -644.9501)
|
||||||
|
sign_text = "PORTALS WORK AS EXPECTED"
|
||||||
|
|
||||||
|
[node name="Teleporter" parent="." unique_id=1261295038 instance=ExtResource("4_gbfbk")]
|
||||||
|
position = Vector2(-1295, -668.58185)
|
||||||
|
paired_teleporter = "C"
|
||||||
|
|
||||||
|
[node name="Teleporter2" parent="." unique_id=392920399 instance=ExtResource("4_gbfbk")]
|
||||||
|
position = Vector2(-1171, -669.5665)
|
||||||
|
paired_teleporter = "C"
|
||||||
|
|
||||||
|
[node name="Sign11" parent="." unique_id=933599424 instance=ExtResource("24_wjb0r")]
|
||||||
|
position = Vector2(-1115, -644.9501)
|
||||||
|
sign_text = "COINS AREN'T REAL"
|
||||||
|
|
||||||
|
[node name="HiddenCoin" parent="." unique_id=1654988120 instance=ExtResource("22_wukud")]
|
||||||
|
position = Vector2(-1063, -662.6739)
|
||||||
|
|
||||||
[connection signal="toggled" from="CanvasLayer/MusicButton" to="CanvasLayer/MusicButton" method="_on_toggled"]
|
[connection signal="toggled" from="CanvasLayer/MusicButton" to="CanvasLayer/MusicButton" method="_on_toggled"]
|
||||||
Reference in new issue
Block a user