Last active
January 21, 2019 11:48
-
-
Save westside/c29cf753991edf1634831ec1df7cc5be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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