Question by
TwoEdgey · Aug 20, 2018 at 09:22 AM ·
positionvector3transform.position
I'm making a small VR game for school and i need a VR sword slash but not sure how to compare the Pos better.
private Vector3 startPos;
private Vector3 endPos;
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "SwordBlade")
{
startPos = other.transform.position;
tgtScript.movespeed = 0.20f;
}
}
private void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "SwordBlade")
{
endPos = other.transform.position;
}
if (other.gameObject.tag == "SwordBlade" && endPos.z < startPos.z || endPos.z > startPos.z)
{
Destroy(target, 3f);
targetBottomLeftRb.isKinematic = false;
targetBottomRightRb.isKinematic = false;
}
This works in the sense they can slash the target but i want to add some sort of buffer on the y axis, So they can't slash all the way downwards on certain targets.
This is a VR project so i cant simply lock the y axis as the players won't be able to be super precise. i was thinking something like it takes the startpos.y and compares with the endpos.y and allows a small increase of decrease, but no idea who to write in code.
Comment