mirror of
https://github.com/ConjureETS/PillowFight.git
synced 2026-03-24 00:50:59 +00:00
First attempt to hit with melee
Signed-off-by: RosimInc <rosim_inc@hotmail.com>
This commit is contained in:
parent
2418d5dec8
commit
6ce7a9b8ab
@ -46,9 +46,15 @@ public class AutoTarget : MonoBehaviour
|
||||
}
|
||||
|
||||
public Transform GetTarget(Vector3 lookingAngle)
|
||||
{
|
||||
return GetTarget(lookingAngle, 2000);
|
||||
}
|
||||
|
||||
public Transform GetTarget(Vector3 lookingAngle, float range)
|
||||
{
|
||||
Transform closest = null;
|
||||
float minAngle = minAngleRange;
|
||||
float minAngle = minAngleRange;
|
||||
float rangeSq = range * range;
|
||||
|
||||
//Debug.Log("looking direction:" + lookingAngle);
|
||||
Debug.DrawRay(transform.position, lookingAngle * 2);
|
||||
@ -56,7 +62,9 @@ public class AutoTarget : MonoBehaviour
|
||||
|
||||
foreach (Transform t in targets)
|
||||
{
|
||||
Vector3 targetDirection = t.transform.position - transform.position;
|
||||
Vector3 targetDirection = t.transform.position - transform.position;
|
||||
if (targetDirection.sqrMagnitude > rangeSq)
|
||||
continue;
|
||||
|
||||
float realAngle = Mathf.Atan2(targetDirection.z, targetDirection.x) * Mathf.Rad2Deg;
|
||||
|
||||
|
||||
@ -236,13 +236,13 @@ public class Child : MonoBehaviour
|
||||
public void Swing()
|
||||
{
|
||||
//1. Determine if there is someone in front
|
||||
Transform t = null; //GetTarget
|
||||
Transform t = null;//_autoTarget.GetTarget(transform.forward, 0.9f);
|
||||
|
||||
if(t == null)
|
||||
return;
|
||||
|
||||
//2. Apply force to the person
|
||||
Vector3 direction = target.transform.position - transform.position;
|
||||
Vector3 direction = t.transform.position - transform.position;
|
||||
|
||||
direction = direction.normalized;
|
||||
|
||||
|
||||
@ -94,9 +94,12 @@ public class ChildController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
if (input.Ranges.ContainsKey("Throw")) {
|
||||
_child.Throw();
|
||||
}
|
||||
//if (input.Ranges.ContainsKey("Throw")) {
|
||||
// _child.Throw();
|
||||
//}
|
||||
|
||||
if (input.Ranges.ContainsKey("Throw"))
|
||||
_child.Swing();
|
||||
}
|
||||
|
||||
private void HandlePlayerButtons(MappedInput input)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user