mercredi 27 mars 2019

Can I code these if statements more efficiënt? [on hold]

I find myself in alot of situations like these and was wondering if I could code these kind of if statements more efficient?

if (velocity.x > runSpeed)
    {
        velocity.x = runSpeed;
    }

    if (velocity.x < -runSpeed)
    {
        velocity.x = -runSpeed;
    }

    if (velocity.z > runSpeed)
    {
        velocity.z = runSpeed;
    }

    if (velocity.z < -runSpeed)
    {
        velocity.z = -runSpeed;
    }

Aucun commentaire:

Enregistrer un commentaire