Random Transform js

People, hey)
Who knows how to make a start function in js script, so it setted var “c” = Random.between “a” and “b”
But they should be:
var a : Transform;
var b : Transform;

a transform is a collection of a Vector3 for translation, Quaternion for rotation, and a Vector3 for scale.

To get a random “between” any of those just get a random value from 0 to 1 (Random.value), and lerp or slerp (linear or spherical) between the two.

like:
Vector3.Lerp(a.posiiton, b.position, Random.value);
Quaternion.Slerp(a.rotation, b.rotation, Random.value);

get these new values and set the transform to it.

And please no double posting your thread…

Lol - I replied to the other thread and read the question completely differently. I thought he meant randomly pick either a or b and assign it to c. :slight_smile:

Yeah I saw that… and it’s a reasonable interpretation as well. I thought that maybe I read it wrong.

lol.

Thanks)

Don’t post duplicate topics please; it’s against the rules.

–Eric

PM from OP requested I post my solution from the bogus thread again since it was lost.

public Transform a;
public Transform b; 
private Transform c;

void Start()
{
    int rand = Random.Range(0, 2);
    c = (rand == 0) ? a : b;
}

Thanks man)

That is C Sharp