Added dynamic spawning and despawning of objects
This commit is contained in:
parent
adbb208436
commit
e0cf8d9755
23 changed files with 794 additions and 350 deletions
22
scripts/GameObjects/Character.cs
Normal file
22
scripts/GameObjects/Character.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using Godot;
|
||||
|
||||
public class Character(Sector sector, Vector3 localCoordinates) : GameObject(sector, localCoordinates)
|
||||
{
|
||||
private Player player;
|
||||
|
||||
public Player InstantiatePlayer()
|
||||
{
|
||||
PackedScene prefab = ResourceLoader.Load<PackedScene>("res://prefabs/gameObjects/player.tscn");
|
||||
Player instance = prefab.Instantiate<Player>();
|
||||
|
||||
instance.PlayerData = this;
|
||||
player = instance;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public override void UpdateNodePosition()
|
||||
{
|
||||
player.GlobalPosition = LocalCoordinates;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue