NPC that shoots at player

This commit is contained in:
MaddoScientisto 2024-08-17 17:00:50 +02:00
commit 30850362ce
11 changed files with 253 additions and 5250 deletions

View file

@ -1,17 +1,17 @@
using Godot;
using Godot;
namespace Cirno.Scripts;
public static class Tools
{
public static T CreateChild<T>(this Node2D node, PackedScene prefab) where T : Node2D
{
if (prefab == null) return null;
var newInstance = prefab.Instantiate<T>();
node.Owner.CallDeferred("add_child", newInstance);
newInstance.Transform = node.GlobalTransform;
newInstance.Position = node.Position;
public static T CreateChild<T>(this Node2D node, PackedScene prefab) where T : Node2D
{
if (prefab == null) return null;
var newInstance = prefab.Instantiate<T>();
node.Owner.CallDeferred("add_child", newInstance);
newInstance.Transform = node.GlobalTransform;
newInstance.Position = node.Position;
return newInstance;
}
}
return newInstance;
}
}