Added pillow hits

Signed-off-by: RosimInc <rosim_inc@hotmail.com>
This commit is contained in:
RosimInc 2015-08-23 14:48:36 -04:00
parent 6ce7a9b8ab
commit 6eae91f4d5
3 changed files with 13 additions and 11 deletions

View File

@ -47,13 +47,12 @@ public class AutoTarget : MonoBehaviour
public Transform GetTarget(Vector3 lookingAngle)
{
return GetTarget(lookingAngle, 2000);
return GetTarget(lookingAngle, 2000, minAngleRange);
}
public Transform GetTarget(Vector3 lookingAngle, float range)
public Transform GetTarget(Vector3 lookingAngle, float range, float minAngle)
{
Transform closest = null;
float minAngle = minAngleRange;
float rangeSq = range * range;
//Debug.Log("looking direction:" + lookingAngle);
@ -63,6 +62,7 @@ public class AutoTarget : MonoBehaviour
foreach (Transform t in targets)
{
Vector3 targetDirection = t.transform.position - transform.position;
Debug.Log(targetDirection.magnitude);
if (targetDirection.sqrMagnitude > rangeSq)
continue;

View File

@ -8,6 +8,7 @@ public class Child : MonoBehaviour
public float JumpForce = 10f;
public float MaxInvulnerableTime = 2f;
public float ThrowForce = 30f;
public float HitForce = 3f;
public float hitPushBackForce = 250f;
public float yAngleVector = 9f;
@ -235,8 +236,10 @@ public class Child : MonoBehaviour
public void Swing()
{
if (pillow == null) return;
//1. Determine if there is someone in front
Transform t = null;//_autoTarget.GetTarget(transform.forward, 0.9f);
Transform t = _autoTarget.GetTarget(transform.forward, 1.2f, 30);
if(t == null)
return;
@ -246,7 +249,7 @@ public class Child : MonoBehaviour
direction = direction.normalized;
t.gameObject.GetComponent<Child>().Push(direction * ThrowForce);
t.gameObject.GetComponent<Child>().Push(direction * HitForce);
}

View File

@ -94,11 +94,10 @@ public class ChildController : MonoBehaviour
}
}
//if (input.Ranges.ContainsKey("Throw")) {
// _child.Throw();
//}
if (input.Ranges.ContainsKey("Throw"))
_child.Throw();
if (input.Ranges.ContainsKey("Hit"))
_child.Swing();
}