samedi 22 octobre 2016

Issues With Unty3d's Random.Range - I don't understand why it's behaving this way

So, I'm generating a Vector2 using Unity's Random.Range, this is basically the x and y value of the direction the mobile should be moving.

    m_CurrentMovementInput = new Vector2
        (Random.Range(-0.75f, 0.75f), Random.Range(-0.75f, 0.75f));

The problem is the mobiles are only moving in diagonal angles. Which makes it seem like when it produces the random it's producing like..

(-0.35f, -0.35f) or (0.35f, -0.35f) or (-0.35f, 0.35f)

Which makes little sense to me as I understand the random function.

I'm sure I can get the desired behaviour by only changing one at a time, but I'd still like to understand it's current behavior.




Aucun commentaire:

Enregistrer un commentaire