예제 #1
0
 override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (shootingTimestamp < Time.time && !hasShot)
     {
         weapon.Shoot(stats.GetTargetPosition() - animator.transform.position);
         hasShot = true;
     }
 }
예제 #2
0
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        stats      = animator.gameObject.GetComponent <DemonStats>();
        controller = animator.gameObject.GetComponent <ZombiemanMovement>();
        Vector3 targetDirection = (stats.GetTargetPosition() - animator.transform.position).normalized;
        Vector3 sidewaysVector  = Vector3.Cross(targetDirection, Vector3.up).normalized;

        sidewaysVector  *= Random.Range(0, 2) * 2 - 1;
        currentDirection = (targetDirection + sidewaysVector).normalized;
    }
    public Vector2 GetRelativeTargetLocation()
    {
        Vector3 targetDirection = (target.GetTargetPosition() - transform.position).normalized;
        Vector3 originDirection = (origin.position - transform.position).normalized;

        float determinant = originDirection.x * targetDirection.z -
                            originDirection.z * targetDirection.x;

        float relativeTargetLocationZ = -Mathf.Sign(Vector3.Dot(originDirection, targetDirection));
        float relativeTargetLocationX = Mathf.Sign(determinant);

        if (Mathf.Abs(determinant) < diagonalShootingThreshold)
        {
            relativeTargetLocationX = 0;
        }
        if (Mathf.Abs(determinant) > 1 - diagonalShootingThreshold)
        {
            relativeTargetLocationZ = 0;
        }

        return(new Vector2(relativeTargetLocationX, relativeTargetLocationZ));
    }