soundvision/UnityProject/Assets/Scenes/Examples/KinectSkeleton/scripts/RightHandFire.cs

27 lines
865 B
C#
Raw Normal View History

2019-11-03 17:27:55 +00:00
using UnityEngine;
using UnityEngine.Experimental.VFX;
namespace cylvester
{
public class RightHandFire : MonoBehaviour
{
[SerializeField] private VisualEffect visualEffect;
private Vector3 previousPosition_;
private float previousCallback_;
public void OnJointDataReceived(Windows.Kinect.Joint joint)
{
var newPosition = new Vector3(joint.Position.X * 10f, joint.Position.Y * 10f, joint.Position.Z * 10f);
var delta = newPosition - previousPosition_;
var vector = delta/(Time.time - previousCallback_);
previousCallback_ = Time.time;
previousPosition_ = newPosition;
visualEffect.SetVector3("EmissionVector", vector);
visualEffect.SetVector3("SourcePosition", newPosition);
}
}
}