void SetOnGround(BottomComponent bottom) { if (!bottom.touchingGround) { var e = new TouchGroundEvent(bottom.actor.guid, true); EgoEvents <TouchGroundEvent> .AddEvent(e); } bottom.touchingGround = true; }
void SetOffGround(BottomComponent bottom) { if (bottom.touchingGround) { var e = new TouchGroundEvent(bottom.actor.guid, false); EgoEvents <TouchGroundEvent> .AddEvent(e); } bottom.touchingGround = false; }
void Handle(TouchGroundEvent e) { constraint.ForEachGameObject((egoComponent, rigidbody, input, movement, actor) => { if (e.actorGuid == actor.guid) { if (e.isTouchingGround && movement.velocity.y <= 0f) { SetOnGround(movement); var setOnGroundEvent = new SetOnGroundEvent(actor.guid); EgoEvents <SetOnGroundEvent> .AddEvent(setOnGroundEvent); } else { movement.onGround = false; } } }); }