Sorry im still pretty noobish with scripting in Unity. i know this has been answered before https://community.leapmotion.com/t/hand-collision-with-trigger-object-in-unity/1976 but i dont really undcerstand it. what is other referring to? and would this script be applied to the leap motion object or the object that is interacting with the leap motion? i want to have an object that increases its velocity every time the leap motion collides with it would i need to use these in an update method or increase the speed of the object in them?
heres the code im using, i added it to a sphere that the hands collide with (basically making wallball that increases speed everytime you hit the ball. it compiles but it doesnt seem to be doing anything
using UnityEngine;
using System.Collections;
public class HandoCollision : MonoBehaviour {
public float speed = 1.0f;
private HandModel GetHand(Collider other)
{
if (other.transform.parent && other.transform.parent.parent.parent &&
other.transform.parent.parent.GetComponent<HandModel> ())
return other.transform.parent.parent.GetComponent<HandModel> ();
else
return null;
}
void onTriggerEnter(Collider other)
{
HandModel handModel = GetHand (other);
if (handModel != null) {
speed ++;
}
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.position = transform.position * speed * Time.deltaTime;
}