DotNet script changes transform

This commit is contained in:
Simon Lübeß
2022-04-27 23:58:50 +02:00
parent 2bac6a8d05
commit 63b9270710
11 changed files with 444 additions and 22 deletions
@@ -1,13 +1,39 @@
using System.Diagnostics;
using System.Numerics;
using DotNetScriptingHelper.Components;
namespace DotNetScriptingHelper;
public class TestEntityScript : ScriptableEntity
{
public int Inty = 1337;
private TransformComponent _transform;
protected override void OnUpdate()
public override void OnCreate()
{
Debug.WriteLine($"My Number is {Inty++}");
_transform = GetTransform();
}
protected override void OnUpdate(GameTime gameTime)
{
float f = (float)Math.Sin(gameTime.TotalSeconds);
Vector3 pos = _transform.Position;
pos.Y = f;
_transform.Position = pos;
float fx = MathF.Sin(gameTime.TotalSeconds * 2) / 2 + 1;
float fy = MathF.Cos(gameTime.TotalSeconds * 2) / 2 + 1;
Vector3 scl = _transform.Scale;
scl.X = fx;
scl.Y = fy;
_transform.Scale = scl;
float fr = MathF.Cos(gameTime.TotalSeconds / 4) * MathF.PI * 10;
_transform.Rotation = Quaternion.CreateFromYawPitchRoll(0, 0, fr);
}
}