🔍

simple head ballin with Kinect

This simple body motion tracking example uses the neck position as a central game element. Through body motion, the user navigates a ball through space with hangings ragdolls, that are flexibly fixed in the space. This creates an unique experience, when the camer view is connected straight through to the balls position.

the basic stage setup. The player spawns around the null position.
keep the inital tracked body visually off – but keep functionallity
creating a ragdoll from an existing mixamo character

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class simple_head_controller : MonoBehaviour
{
    //movin a ball with the head and make the camera move along smoothed
    public GameObject myhead;
    public GameObject ball;


    public Transform camtrans;
    public GameObject target;
    public Vector3 off = new Vector3(0,0,-3f);
    public float smoothspeed = .03f;
    
   

    // Update is called once per frame
    void Update()
    {
 
         Vector3 inv = myhead.transform.position;
         inv.x *= -1f;  // switch x axis 
         ball.transform.position =  inv;

          if(target.activeSelf){
            camtrans.position  = Vector3.Lerp(camtrans.position, target.transform.position + off, smoothspeed);
        }
 
    }
}