Home>
As the title says, I don't know how to implement it due to lack of mathematical knowledge and unfamiliarity with Unity's vector calculation.
When I looked up how to get the normal vector from two vectors, I found a method, but I don't know the opposite.
I hope you can assume the position of the plane so that it passes through the origin.
Thanks for your cooperation.
>>>I've solved it, so I'll lightly paste the method below.
// Final method form
Vector3 GetPerpendicularVec (Vector3 vec) {
var randomNum1 = Random.Range (1f, 1f);
var randomNum2 = Random.Range (1f, 1f);
while (randomNum1 == 0&randomNum2 == 0) {// About the possibility that the length of the vector is 0
randomNum1 = Random.Range (1f, 1f);
randomNum2 = Random.Range (1f, 1f);
}
float number;
Vector3 targetVec = Vector3.zero;
// Extract one random vector from the plane
if (vec.x! = 0) {
number = (randomNum1 * vec.y randomNum2 * vec.z)/vec.x;
targetVec = new Vector3 (number, randomNum1, randomNum2);
} else if (vec.y! = 0) {
number = (randomNum1 * vec.x randomNum2 * vec.z)/vec.y;
targetVec = new Vector3 (randomNum1, number, randomNum2);
} else if (vec.z! = 0) {
number = (randomNum1 * vec.x randomNum2 * vec.y)/vec.z;
targetVec = new Vector3 (randomNum1, randomNum2, number);
} else {
Debug.LogAssertion ("The length of the given vector is 0");
}
return targetVec.normalized;
}

Answer # 1
Related articles
 unity3d how to shorten code that is too long
 unity3d  how to reduce image quality in unity
 i want to fire a unity3d fps shell forward
 unity3d  i want to know how to find the plane vector when going down a slope
 unity3d  [unity] i want to prepare multiple types of particles for one object
 unity3d  unity i want to change the ongui character from another script
 unity3d  i want to manipulate objects with hmd (unity, oculus rift s)
 unity3d  multimonitor with unity
 unity3d  i don't know how to record and play my actions in unity 3d
 unity3d  i want to bend my hips in the direction of the unity character's viewpoint
 unity3d  unity steamvr object automatic generation
 Unity implements vector rotation at any angle around any axis
 unity3d  unity controller change
 unity want to rotate randomly to create an object
 i want to specify which vector to direct to target with unity3d lookat function
 i want to turn unity c # direction vector at a specified angle
 unity3d  objects using probuilder in unity
 unity3d  i want to save external data loaded in unity runtime
 unity3d  unity doesn't fix the error
Trends
 python  you may need to restart the kernel to use updated packages error
 php  coincheck api authentication doesn't work
 php  i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
 [php] i want to get account information using coincheck api
 the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
 javascript  how to check if an element exists in puppeteer
 i want to call a child component method from a parent in vuejs
 python 3x  typeerror: 'method' object is not subscriptable
 dart  flutter: the instance member'stars' can't be accessed in an initializer error
 xcode  pod install [!] no `podfile 'found in the project directory
A normal vector is originally a vector for defining a plane.
Once the normal vector and any one point on the plane are determined, the plane is determined and any vector on the plane is perpendicular to the normal vector.
When the normal vector is (a, b, c), the equation for the plane containing the origin (0,0,0) is
It becomes ax + by + cz = 0.
If there is no limit to the length of the vector to be obtained, x and y can be randomly determined, and only z can be obtained from the above formula to obtain a vertical vector.
However, if the length is 0, it has no meaning as a vector, so x = 0 and y = 0 should be excluded.