set rotation from spawn point
This commit is contained in:
parent
a361350ec2
commit
b4faa5d35b
@ -2,7 +2,7 @@
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/Main.gd" id="1_2yjjx"]
|
||||
[ext_resource type="PackedScene" uid="uid://deff7lt34nj0h" path="res://Spaces/Dungeon.tscn" id="2_4gs22"]
|
||||
[ext_resource type="PackedScene" uid="uid://b83k3b5x1wmyl" path="res://Scenes/Player.tscn" id="3_eq7hn"]
|
||||
[ext_resource type="PackedScene" uid="uid://d3e3a6xdwo2dp" path="res://Scenes/Player.tscn" id="3_eq7hn"]
|
||||
|
||||
[sub_resource type="Environment" id="Environment_pn2uj"]
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://b83k3b5x1wmyl"]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://d3e3a6xdwo2dp"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/Player.gd" id="1_m1g7d"]
|
||||
|
||||
|
@ -3,8 +3,10 @@ extends Node3D
|
||||
|
||||
func _ready():
|
||||
add_child($Dungeon.generate_geometry())
|
||||
$Player.position = $Dungeon.get_spawn_point()
|
||||
var spawn = $Dungeon.get_spawn()
|
||||
$Player.position = spawn.position
|
||||
$Player.position.y += 0.5
|
||||
$Player.rotation = spawn.rotation
|
||||
|
||||
|
||||
func _process(delta):
|
||||
|
@ -21,14 +21,14 @@ func generate_geometry() -> Node3D:
|
||||
return root
|
||||
|
||||
|
||||
func get_spawn_point() -> Vector3:
|
||||
func get_spawn() -> SpaceSpawn.Desc:
|
||||
var stack := [self]
|
||||
|
||||
while stack:
|
||||
var node = stack.pop_front()
|
||||
for child in node.get_children():
|
||||
if child is SpaceSpawn:
|
||||
return child.space_position(self)
|
||||
return child.get_spawn_desc(self)
|
||||
stack.push_back(child)
|
||||
|
||||
return Vector3.ZERO
|
||||
return null
|
||||
|
@ -5,6 +5,14 @@ extends SpaceEntity
|
||||
class_name SpaceSpawn
|
||||
|
||||
|
||||
func space_position(space: Space) -> Vector3:
|
||||
class Desc extends RefCounted:
|
||||
var position: Vector3
|
||||
var rotation: Vector3
|
||||
|
||||
|
||||
func get_spawn_desc(space: Space) -> Desc:
|
||||
# todo: Get current region elevation
|
||||
return Vector3(global_position.x * space.unit_scale, 0, global_position.y * space.unit_scale)
|
||||
var desc := Desc.new()
|
||||
desc.position = Vector3(global_position.x * space.unit_scale, 0, global_position.y * space.unit_scale)
|
||||
desc.rotation.y = rotation_degrees
|
||||
return desc
|
||||
|
@ -31,7 +31,7 @@ wall_texture = ExtResource("3_ondo6")
|
||||
|
||||
[node name="Spawn" type="Sprite2D" parent="Room"]
|
||||
position = Vector2(-48, 32)
|
||||
rotation = 0.159622
|
||||
rotation = 1.83259
|
||||
scale = Vector2(0.25, 0.25)
|
||||
texture = ExtResource("3_7vff1")
|
||||
script = ExtResource("4_rhl23")
|
||||
|
Loading…
Reference in New Issue
Block a user