Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        currentState = new GroundedState();

        input         = gameObject.AddComponent <PlayerInputManager>();
        activeRagdoll = GetComponent <ActiveRagdoll>();

        if (handR)
        {
            GameObject hookGunGO = (GameObject)Instantiate(Resources.Load("Prefabs/HookGun"));
            HookGun    hookGun   = hookGunGO.GetComponent <HookGun>();
            hookGun.Equip(handR, handR.position + 0.25f * handR.transform.forward,
                          handR.rotation, false);
            hookGun.setControls(1);
            hookGun.setColor(Color.red);
            hookGun.cursor.cursorImage = cursorImage;
        }

        if (handL)
        {
            GameObject   magnetoGloveGO = new GameObject();
            MagnetoGlove magnetoGlove   = magnetoGloveGO.AddComponent <MagnetoGlove>();
            magnetoGlove.Equip(handL, handL.position, handL.rotation, false);

            /*
             * GameObject ballHookGunGO = (GameObject)Instantiate(Resources.Load("Prefabs/HookGun"));
             * HookGun ballHookGun = ballHookGunGO.GetComponent<HookGun>();
             * ballHookGun.AttachTo(handL, handL.position + 0.25f * handL.transform.forward,
             *              handL.rotation, false);
             * ballHookGun.setControls(0);
             * ballHookGun.setColor(Color.blue);
             * ballHookGun.cursor.cursorImage = cursorImage;
             */
        }
    }
Пример #2
0
    private void Update()
    {
        currentState = currentState.UpdateStep(this);
        playerCamera.UpdateCameraTargetRotation(input.mouseXDelta, input.mouseYDelta);

        MagnetoGlove magnetoGlove = handL.GetComponent <MagnetoGlove>();

        if (magnetoGlove)
        {
            magnetoGlove.Handle(this);
        }
    }
Пример #3
0
    private void FixedUpdate()
    {
        Collider[] colliders             = new Collider[numPlayers];
        LayerMask  magnetogloveLayerMask = LayerMask.GetMask("MagnetoGlove");
        int        overlapCount          = Physics.OverlapSphereNonAlloc(transform.position, influnceRange, colliders, magnetogloveLayerMask);

        for (int i = 0; i < overlapCount; i++)
        {
            Collider     collider     = colliders[i];
            MagnetoGlove magnetoGlove = collider.GetComponent <MagnetoGlove>();
            if (collider.transform != transform.parent && magnetoGlove.IsMagnetizing)
            {
                Vector3 r = magnetoGlove.ballTarget.position - transform.position;
                //Vector3 homingForce = InverseSquareForceLaw(magnetoGlove.Strength, r);
                //Vector3 homingForce = InverseForceLaw(magnetoGlove.Strength, r);
                Vector3 homingForce = PControllerWithPredictionForce(magnetoGlove.ballTarget.position, magnetoGlove.ballTargetVelocity);
                ballRb.AddForce(homingForce);
                magnetoGlove.ApplyForceOnHand(-homingForce, ForceMode.Force);
            }
        }
    }