mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-06 05:01:53 +00:00
Scripting: FindEntityWithName and get script instance
+ Some C# UUID stuff + Added some Mono functions + ScriptEngine: + ID -> ScriptInstance map in ScriptEngine + GetManagedInstance + Fixed Scene not visible after loading a new scene + Renamed OnViewportResize to SetViewportSize for Scene and SceneRenderer
This commit is contained in:
@@ -54,6 +54,8 @@ class MyTestEntity : Entity
|
||||
|
||||
public MyStruct AStruct;
|
||||
|
||||
public Camera Camera;
|
||||
|
||||
/// <summary>
|
||||
/// Called after the script component was created. (The entity might not be fully created yet)
|
||||
/// </summary>
|
||||
@@ -61,7 +63,16 @@ class MyTestEntity : Entity
|
||||
{
|
||||
Log.Info($"Create! {UUID}");
|
||||
|
||||
Log.Info($"Jump Force: {JumpForce}");
|
||||
|
||||
_rigidBody ??= GetComponent<RigidBody2D>() ?? AddComponent<RigidBody2D>();
|
||||
|
||||
Camera = FindEntityWithName("Camera").As<Camera>();
|
||||
|
||||
if (Camera == null)
|
||||
{
|
||||
Log.Error("Camera not found.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -82,6 +93,12 @@ class MyTestEntity : Entity
|
||||
force.X += MoveForce * deltaTime;
|
||||
}
|
||||
|
||||
if (Input.IsKeyPressed(Key.Q))
|
||||
Camera.DistanceFromPlayer -= deltaTime;
|
||||
|
||||
if (Input.IsKeyPressed(Key.E))
|
||||
Camera.DistanceFromPlayer += deltaTime;
|
||||
|
||||
if (Input.IsKeyPressing(Key.Space))
|
||||
{
|
||||
force.Y += JumpForce;
|
||||
|
||||
Reference in New Issue
Block a user