unity – GA measurement protocol without Firebase

I successfully used the measurement log for my websites and web apps to collect analysis data.

Now I'm trying to implement it in my game, but nothing happens. Debug URL gives a valid answer:

    GA Response:{
  "hitParsingResult": ( {
    "valid": true,
    "parserMessage": ( ),
    "hit": "/debug/collect?XXXXXXXX"
  } ),
  "parserMessage": ( {
    "messageType": "INFO",
    "description": "Found 1 hit in the request."
  } )
}

However, a non-debug URL does not have a track record. What could be the reason?
Here are my hit dates:

  private IEnumerator CollectScreenView(string screen)
    {

        int count = 0;
        while (count < 3)
        {

            WWWForm formData2 = new WWWForm();
            formData2.AddField("v", "1");
            formData2.AddField("tid", "UA-XXXXXXXX-X");
            formData2.AddField("cid", uuid());
            formData2.AddField("t", "pageview");
            formData2.AddField("dh", url);
            formData2.AddField("dp",screen);
            formData2.AddField("dt", screen);

            UnityWebRequest www = UnityWebRequest.Post("https://www.google-analytics.com/collect",formData2);

            yield return www.SendWebRequest();

            if (www.isNetworkError)
            {
                Debug.Log("Can't send data to GA");
            }
            else
            {
                Debug.Log("GA Status:" + www.GetResponseHeader("Status"));
                Debug.Log("GA Response:" + www.downloadHandler.text);
                break;
            }

        }
    }

unity – null reference to gameObject that was successfully referenced

It is exactly as the title says. I get a zero reference error even though I properly referenced the object. I tested my code to show that the result is always exactly what I need. However, the code always returns an error when it is put into practice.

                if(hit == true && canSee.transform.CompareTag("Unit"))
                {
                    //var Obehaviour = other.gameObject.transform.parent.gameObject.GetComponent().Health; <--- Error is here.
                    float Health = other.gameObject.transform.parent.gameObject.GetComponent().Health;
                    float fullHealth = other.gameObject.transform.parent.gameObject.GetComponent().MaxHealth;
                    //Debug.Log("Object " + other.gameObject.transform.parent.gameObject);
                    //Debug.Log("Component and name " + Obehaviour.Name);
                    ReferenceScript.GetComponent(other.gameObject.transform.parent.gameObject);
                    if(Health < fullHealth)
                    {
                        if(fullHealth - Health < Ubehaviour.supplies)
                        {
                            Health += Ubehaviour.supplyTransferRate;
                            Health = Mathf.Clamp(Health, 0, fullHealth);
                            other.gameObject.transform.parent.gameObject.GetComponent().UpdateHealth();
                            Ubehaviour.supplies -= Ubehaviour.supplyTransferRate;
                            Ubehaviour.supplies = Mathf.Clamp(Ubehaviour.Health, 0, Ubehaviour.maxSupplies);
                            Ubehaviour.LoseSupplies();
                        }
                        else
                        {
                            return;
                        }

                    }
                }

As shown in the code above, I tried to get the values ​​I needed by storing them in variables other than caching the entire class. But that didn't work either. What could be wrong? The following debugs also work fine.

Unity – Why does Physics.Raycast always return my game item instead of the item I clicked on?

I have a 3D world. I want to know when the player clicks on a game object in the world.

this picture

In this picture I have 2 objects on which I want to see a mouse click. There is a collider on the white ball. Not the dumpster. The behavior is the same as stated below.

I dragged the mouse down. If I check that RaycastHitI always get the game object transformed and not the game object I clicked on in the world. When I remove the Raycaster checks, I am moved down for anything in the game without simply hovering over the object. I have to be able to distinguish between clicks on different game objects.

I found a post here and added a PhysicsRayCaster, but that didn't change the behavior. The problem is not getting the event. My problem is recognizing the game object that the player clicked on in the world.

Here is my code:

public class InventoryItemSearchHandler : MonoBehaviour
{     
    private void Update()
    { 
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = UnityEngine.Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                // CompareTo always fails because hit.transform.name is always "Player" and
                // not the name of the object clicked on
                if (0 == hit.transform.name.CompareTo(transform.name))
                {
                    print("mouse down");
                }
            }
        }
    }
}

TO EDIT:
In the picture below (compared to the picture above), I get the correct transformation for the RaycastHit type when I click on the white ball (and when I click on the trash, I get the player transformation as stated above).

Enter image description here
So it looks like the player object is in the way. What would it do?

Unity – The children of a transformation are in reverse order

I'm making a simple turn-based 4-player card game.
At one point, a player can "open" his hand on the table. While the player is doing this, I want the cards to be oriented so that the left side of everyone is visible.

The cards look like this in my hand.
Enter image description here

When I carry them on the table, they look like this
Enter image description here

Not only is the order reversed, which I don't mind, but the cards are now not visible.

This is what the green area in the Inspector looks like
Enter image description here

I don't want cards to change their shape to fill the area, nor do I want them to leave the green area.

If I deselect Control Child SizeThe cards are oriented the way I want them to, but now they're too widely spread and out of the green.

Is there a way to achieve the desired behavior?

Isometric output of the Z-as-Y sort order in Unity

I'm having problems with the Z-as-Y Tilometric sort order in Unity. I try to paint two levels of tiles on my tile map. When I add tiles that I expect to be "below" / "behind" my upper level, they partially obscure the tiles above. (The visual discrepancy is shown on the right in the image I attached.)

My two levels are currently painted at Z = 0 and Z = 2. I've been looking for a handful of new arrivals:

  • The sort mode is set to individual
  • Sort order in the top right
  • Transparency sort axis set to X = 0, Y = 1, Z = 0
  • I scrubbed for possible optical illusions using normal (not Z-like-Y) isometry to look at my tiles and make sure I have a coherent grid.

Am I missing something here? My understanding was that with Z-as-Y, I could use a single tile map to paint tiles at multiple heights, but this display problem in my sort order makes me think that Z-as-Y is not quite enough for that Job to do.

Problematic tile

Unity – When I move my character / camera, the environment stutters

I am learning to make a tilebased game with Unity using the Zelda Alttp assets.
I only have tiles, a camera and a moving character with a Rigidbody2D and a CircleCollider.

When the camera follows the character, the scene feels jerky.

The information:

  • The camera uses the 2D Pixel Perfect package.
  • The character moves over Rigidbody2D.MovePosition () in the FixedUpdate Method:

Code:

void Update()
{
    float yInput;
    float xInput;

    #region yMovement
    if (Input.GetKey(keyMoveTop))
    {
        if (Input.GetKey(keyMoveBot))
        {
            yInput = 0f;
        }
        else yInput = 1f;
    }
    else if (Input.GetKey(keyMoveBot))
    {
        yInput = -1f;
    }
    else yInput = 0f;
    #endregion

    #region xMovement
    if (Input.GetKey(keyMoveLeft))
    {
        if (Input.GetKey(keyMoveRight))
        {
            xInput = 0f;
        }
        else xInput = -1f;
    }
    else if (Input.GetKey(keyMoveRight))
    {
        xInput = 1f;
    }
    else xInput = 0f;
    #endregion

    //Walking
    isWalking = Input.GetKey(keyMoveWalk);
    moveDirection = Vector2.ClampMagnitude(transform.right * xInput + transform.up * yInput, 1f);
}

private void FixedUpdate()
{
    _rb.MovePosition(_rb.position + moveDirection * (isWalking ? walkSpeed : runSpeed) * Time.fixedDeltaTime);
}

You can see the problem here:
https://youtu.be/MA2zZPME5X4

Edit: All my motion code added

Unity – My platform disappears

Enter image description here

Hello, I have a problem right now. I don't seem to understand what this code does because I just copied it from someone, but my problem is that my platform disappears when it almost reaches the end of the platform. What does it matter, can you tell me why?


SCRIPT

public class groundSpawner : MonoBehaviour
{
(SerializeField)
Transform spawnPoint;

(SerializeField)
GameObject() obstacles;

(SerializeField)
float spawnRate;
public float nextSpawn;

private void Start()
{
    nextSpawn = Time.time + spawnRate;
}

private void FixedUpdate()
{
    if (Time.time > nextSpawn)
        SpawnObstacle();
}

void SpawnObstacle()
{
    nextSpawn = Time.time + spawnRate;
    int randomObstacle = Random.Range(0, obstacles.Length);
    Instantiate(obstacles(randomObstacle), spawnPoint.position, Quaternion.identity);
}

}

Physics – Vertical pressure does not immediately drop the object [UNITY]

An object (wall) continuously moves forward on the X axis with a simple script:

public float speed = .2f;
void FixedUpdate()
{
    transform.Translate(speed, 0, 0);
}

It pushes another object (penguin) that is affected by gravity. It can also "jump" with a script from:

public void Jump()
{
    transform.position = new Vector3(transform.position.x, transform.position.y + 1.15f, transform.position.z);
}

When jumping over a certain value of speed, such as 0.2f, the penguin does not fall to the ground until it reaches a speed vector of approximately (0.0, -10.0 f, 0.0),

Set speed to 0,02f makes it fall right away.

How can I achieve the same result with a higher speed value?

I attached the setup of the two objects in the Inspector:Enter image description here

unity – SetTextureOffset in meters per second speed

I have this code snippet that fakes the tile displacement speed. Now I want to set the speed in meters per second. how to divide or multiply that I get a number that is meters per second:

public float scrollSpeed = 0.5f;

    Renderer rend;

    void Start()
    {
        rend = GetComponent();
    }

    // Update is called once per frame
    void Update()
    {
        //rend.material.SetTextureOffset("_MainTex", new Vector2(offset, 0));
        //rend.material.SetTextureOffset("_NormalMap", new Vector2(offset, 0));

        float offset = Time.time * scrollSpeed * SpeedSliderController.globalSpeed;
        ChangeDetailTextureOffSet(rend.material, offset, 0f);
    }

    public void ChangeDetailTextureOffSet(Material Mat, float scaleX, float scaleY)
    {
        Mat.SetTextureOffset("_DetailAlbedoMap", new Vector2(scaleX, scaleY));
    }

How do I move 2 meters per second?