set rotation from spawn point
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user