2019-11-03 17:27:55 +00:00
|
|
|
|
using UnityEngine;
|
2020-03-04 20:47:24 +00:00
|
|
|
|
using UnityEngine.VFX;
|
2019-11-03 17:27:55 +00:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|