mirror of
https://github.com/hanzoai/ProjectTinySamples.git
synced 2026-09-24 00:01:34 +00:00
27 lines
724 B
C#
27 lines
724 B
C#
using Unity.Entities;
|
|
|
|
namespace TinyPhysics.Systems
|
|
{
|
|
/// <summary>
|
|
/// Detect when an object is tapped and set its jump trigger
|
|
/// </summary>
|
|
[UpdateBefore(typeof(MovementSystem))]
|
|
public class JumpWithTapSystem : SystemBase
|
|
{
|
|
protected override void OnUpdate()
|
|
{
|
|
Entities.WithAll<JumpWithTap>().ForEach((ref Tappable tappable, ref Jumper jumper) =>
|
|
{
|
|
if (tappable.IsTapped)
|
|
{
|
|
// Set jump trigger
|
|
jumper.JumpTrigger = true;
|
|
|
|
// Consume tap
|
|
tappable.IsTapped = false;
|
|
}
|
|
}).ScheduleParallel();
|
|
}
|
|
}
|
|
}
|