- Home /
Kinect and raycast, can't get it done
Hi everyone, I'm working on a project where i use a Kinect V1, with the asset "kinect with MS-SDK", and also if I got all the gestures and joint tracking I need, I'm not able to implement a simple "hover" status.
I'm using the raycast on the Hand Indicator implemented by the "kinect with ms-sdk" framework and trying to catch 4 areas with a collider on them, but yet not a single object is hit.
This is the code I'm using on my HandCursor Object, which is the one tracking user's right hand:
using UnityEngine;
using System.Collections;
public class HandScript : MonoBehaviour {
Transform target;
Camera camera;
void Start() {
target = transform;
camera = Camera.main;
}
void Update() {
}
void FixedUpdate(){
Vector3 screenPos = camera.WorldToScreenPoint(target.position);
Debug.Log("target is " + screenPos.x + " pixels from the left and "+ screenPos.y + " pixels from bottom");
Vector3 fwd = transform.TransformDirection(Vector3.forward);
Ray ray = camera.ScreenPointToRay(screenPos);
ray.direction = fwd;
RaycastHit hit;
if(Physics.Raycast(ray, out hit, 200f))
print("There is something in front of the object!");
Debug.DrawRay(ray.origin, ray.direction * 200, Color.yellow);
}
}
Then I have a canvas with an image inside and 4 empty gameobjects with a collider to trigger the raycast, but seems I'm doing something wrong :(
Any help is apreciated and thanks in advance guys :)
Your answer
Follow this Question
Related Questions
get custom class instance of collider hit by raycast? 1 Answer
Physics.Raycast not hitting anything 1 Answer
Detect only UI button click 3 Answers
Raycast to align character on MeshCollider normals 1 Answer
I need help to mesh collision. 0 Answers