How to write a "or "statement & a if Else with or condition?

Hi Guys,

I have 2 questions,

  1. How do i insert a Or Random Range insert this function?

     function ResetPosition ()
    

    {
    transform.position.y = 71;
    transform.position.x = Random.Range(-11 ,-10))||(Random.Range(10, 11);
    transform.position.z = 0;
    rigidbody.velocity = Vector3.zero;

    }

  2. How do I add a or condition in the if else statement?

    if (randomNo >5)
    {
    transform.position.x -= speed * Time.deltaTime;
    if(transform.position.x < -6.1 )

     {
     	//Instantiate(prefab, transform.position, Quaternion.identity);
     	transform.position.y = Random.Range(-2.3, 1.4);
     	transform.position. x = Random.Range (-5,5);
     	transform.position.z = -3;
     }
    

    }

    else
    {
    transform.position.x += speed * Time.deltaTime;
    if(transform.position.x > 6.1 )

     {
     	//Instantiate(prefab, transform.position, Quaternion.identity);
     	transform.position.y = Random.Range(-2.3, 1.4);
     	transform.position. x = Random.Range (-5,5);
     	transform.position.z = -3;
     }
    

    }
    I wish to combine <-6.1 & > 6.1 together.

Question 1)

I would do the following, altough I’m not 100% sure there is no more elegant way:

function ResetPosition ()
{
    transform.position.y = 71;

    if(Random.value<0.5)
    {
        transform.position.x = Random.Range(-11 ,-10);
    }
    else
    {
        transform.position.x = Random.Range(10, 11);
    }
    transform.position.z = 0;
    rigidbody.velocity = Vector3.zero;

}
  1. It is not clear what you are trying to do here. Please explain.

if(transform.position.x > 6.1 || transform.position.x < -6.1)

This way, as you planned, you can combine the two branches of your if-statement into a single one.