Skip to content

Instantly share code, notes, and snippets.

@westside
Last active January 21, 2019 11:48
Show Gist options
  • Save westside/c29cf753991edf1634831ec1df7cc5be to your computer and use it in GitHub Desktop.
Save westside/c29cf753991edf1634831ec1df7cc5be to your computer and use it in GitHub Desktop.
using UnityEngine;
namespace Bhaptics.Tact.Unity
{
public class TactReceiver : MonoBehaviour
{
public PositionTag PositionTag = PositionTag.Body;
public bool IsActive = true;
void OnTriggerEnter(Collider bullet)
{
if (IsActive)
{
Handle(bullet.transform.position, bullet.GetComponent<TactSender>());
}
}
void OnCollisionEnter(Collision bullet)
{
if (IsActive)
{
Handle(bullet.contacts[0].point, bullet.gameObject.GetComponent<TactSender>());
}
}
private void Handle(Vector3 contactPoint, TactSender tactSender)
{
if (tactSender != null)
{
////////////////////// please change this part
var targetCollider = // get collider from the body not from hand // GetComponent<Collider>();
tactSender.Play(PositionTag, contactPoint, targetCollider);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment