// Use this for initialization
    void Start()
    {
        actions = GetComponent <UnitActions>();
        if (actions == null)
        {
            Debug.LogError("actions is null in complexactions");
        }

        sensor = GetComponent <UnitSensor>();
        if (sensor == null)
        {
            Debug.LogError("sensor is null in complexactions");
        }

        path           = new NavMeshPath();
        relativeHeight = new Vector3(0, transform.position.y, 0);
        if (relativeHeight.y > 1.6)
        {
            Debug.Log("make sure to spawn agent right above ground");
        }

        stuckIteration       = -1;
        obstaclesCheckExtend = new Vector3(0.2f, transform.position.y, 1f);
        lastJumpTime         = Time.timeSinceLevelLoad;
        lastStuckIncrement   = Time.realtimeSinceStartup;
        agentLayer           = LayerMask.GetMask("Agent");
        physicalLayer        = LayerMask.GetMask("PickupAble");


        if (sensor.rightStartWeapon != null)
        {
            Physics.IgnoreCollision(GetComponent <CapsuleCollider>(), sensor.rightStartWeapon.GetComponent <Collider>());
            actions.PickupObject(sensor.rightStartWeapon, sensor.rightHand, sensor.rightWeaponPos);
        }
        if (sensor.leftStartWeapon != null)
        {
            Physics.IgnoreCollision(GetComponent <CapsuleCollider>(), sensor.leftStartWeapon.GetComponent <Collider>());
            actions.PickupObject(sensor.leftStartWeapon, sensor.leftHand, sensor.leftWeaponPos);
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        // ALL of this is debug
        // TODO: remove
        if (doMoveTowards)
        {
            actionSet.MoveTowards(target.position, moveSpeed);
        }
        if (doJump)
        {
            actionSet.Jump(jumpHeight);
            doJump = false;
        }
        if (doPickupRight)
        {
            Physics.IgnoreCollision(GetComponent <CapsuleCollider>(), rightPickupTarget.GetComponent <Collider>());
            actionSet.PickupObject(rightPickupTarget, rightHand, rightHand.Find("WeaponPos"));
            doPickupRight = false;
        }
        if (doPickupLeft)
        {
            Physics.IgnoreCollision(GetComponent <CapsuleCollider>(), leftPickupTarget.GetComponent <Collider>());
            actionSet.PickupObject(leftPickupTarget, leftHand, leftHand.Find("WeaponPos"));
            doPickupLeft = false;
        }

        /*if (doDrop)
         * {
         *  Vector3 velocity = hand.GetComponent<Rigidbody>().velocity;
         *  actionSet.DropObject(pickupTarget, hand.transform, velocity);
         *  doDrop = false;
         * }*/
        if (doActivateRight)
        {
            actionSet.ActivateObject(rightPickupTarget, rightHand.Find("WeaponPos"));
        }
        if (doActivateLeft)
        {
            actionSet.ActivateObject(leftPickupTarget, leftHand.Find("WeaponPos"));
        }
        if (doAimAtRight)
        {
            rightSlerpPos += 0.2f;
            actionSet.AimAt(rightHand, target.position, rightSlerpPos);
            if (rightSlerpPos > 1)
            {
                rightSlerpPos = 0;
            }
            //doAimAtRight = false;
        }
        if (doAimAtLeft)
        {
            leftSlerpPos += 0.2f;
            actionSet.AimAt(leftHand, target.position, leftSlerpPos);
            if (leftSlerpPos > 1)
            {
                leftSlerpPos = 0;
            }
        }
        if (doCrouch)
        {
            actionSet.Crouch(leg, originalHeight, 0.3f);
            doCrouch = false;
        }
        if (doStandup)
        {
            actionSet.StandUp(leg, originalHeight);
            doStandup = false;
        }
        if (doReload)
        {
            actionSet.ReloadWeapon(rightPickupTarget);
            actionSet.ReloadWeapon(leftPickupTarget);
            doReload = false;
        }
        if (doOrientate)
        {
            actionSet.TurnTowards(target, 1.0f, 2.0f, 7f);
        }
        if (setDestinationWithStrafe)
        {
            setDestinationWithoutStrafe = false;
            setDestinationWithStrafe    = activitySet.GoTowardsDestination(destination.position);
            actionSet.TurnTowards(destination, 1.0f, 2.0f, 7f);
        }
        if (setDestinationWithoutStrafe)
        {
            setDestinationWithStrafe    = false;
            setDestinationWithoutStrafe = activitySet.GoTowardsDestination(destination.position, false);
            //actionSet.TurnTowards(destination, 1.0f, 2.0f, 7f);
        }
        //animator.SetInteger("RoutineStatus", routineStatus);
    }