-
Notifications
You must be signed in to change notification settings - Fork 2
Scripting API
Victor edited this page Jan 17, 2023
·
3 revisions
Components are structs that can only contain variables.
[Component]
public struct PlayerComp
{
public float Speed;
public bool Grounded;
}Behaviours is the base class for a scriptable system.
Called at the start of the game
void Awake(){}Called at the after Awake
void Init(){}Called every frame
void Update(){}[Component]
public struct PingPongComp
{
public float speed;
public float turnTime;
public float turnTimer;
public int direction;
}
class MovePingpong : Behaviour
{
void Update()
{
ref Transform3D t3d = ref GetComponent<Transform3D>();
ref PingPongComp ppc = ref GetComponent<PingPongComp>();
ppc.turnTimer += Time.DeltaTime();
Vector3 forward = Math.CalculateForward(ref t3d);
if(ppc.turnTimer >= ppc.turnTime)
{
ppc.turnTimer = 0.0f;
ppc.direction *= -1;
}
t3d.LocalPosition += forward * ppc.speed * Time.DeltaTime() * ppc.direction;
}
}