Skip to content

Instantly share code, notes, and snippets.

@TORISOUP
Last active August 29, 2015 14:17
Show Gist options
  • Save TORISOUP/e07f9c098be54c4f35d7 to your computer and use it in GitHub Desktop.
Save TORISOUP/e07f9c098be54c4f35d7 to your computer and use it in GitHub Desktop.
using UnityEngine;
using UniRx;
namespace UniRxSamples
{
public class OnGroundedScript : ObservableMonoBehaviour
{
public override void Start()
{
var characterController = GetComponent<CharacterController>();
var particleSystem = GetComponentInChildren<ParticleSystem>();
UpdateAsObservable()
.Select(_ => characterController.isGrounded)
.DistinctUntilChanged()
.Where(x => x)
.Subscribe(_ => particleSystem.Play());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment