55 lines
1.5 KiB
GDScript
55 lines
1.5 KiB
GDScript
extends Node3D
|
|
|
|
var oldobject:Node3D = null
|
|
@onready var player_ptr = $player
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
$player.connect("switch_to_ship", self.switch_to_ship.bind() )
|
|
# $player_ship.set_process(false)
|
|
# $player_ship.hide()
|
|
|
|
|
|
func change_creature( new_model_path ):
|
|
var new_model = load( new_model_path )
|
|
if new_model:
|
|
new_model = new_model.instantiate()
|
|
new_model.translate($player.get_position())
|
|
if $player:
|
|
print("Remove old")
|
|
var old_model = $player
|
|
self.remove_child( old_model )
|
|
#self.animation_object = null
|
|
old_model.queue_free()
|
|
if new_model:
|
|
print("Add new")
|
|
self.add_child( new_model )
|
|
#new_model.connect( "animation_finished", self, "_on_creature_animation_finished" )
|
|
# new_model.duplicate_meshes()
|
|
|
|
func switch_to_ship(near_boat):
|
|
near_boat.hide()
|
|
oldobject = near_boat
|
|
print("GO switch_to_ship:", str(near_boat))
|
|
|
|
var new_model = load( "res://player/player_ship/player_ship.tscn" )
|
|
if new_model:
|
|
new_model = new_model.instantiate()
|
|
print("A:", near_boat.get_position())
|
|
print("B:", near_boat.get_global_transform().origin )
|
|
var newpos:Vector3 = near_boat.get_global_transform().origin
|
|
new_model.translate(newpos)
|
|
if $player:
|
|
print("Remove old")
|
|
var old_model = $player
|
|
self.remove_child( old_model )
|
|
#self.animation_object = null
|
|
old_model.queue_free()
|
|
if new_model:
|
|
print("Add new")
|
|
self.add_child( new_model )
|
|
# $player.set_process(false)
|
|
# $player.hide()
|
|
# $player_ship.show()
|
|
# $player_ship.set_process(true)
|