Post by cursedereaper on May 1, 2019 6:49:00 GMT
After I played arround with my FSM Decision that added the bool of my Stun Script to the FSM which allowed me to stop the movement of the FSM to prevent it from attacking. I realized that it felt wrong that my rather weak main character was able to move a 800 kilo heavy enemy arround while running.
My Solution was a new FSM Action which costed quite some time to write down. I freezed all Rigidbody constrains while my enemy was stunned which made my player stop draging it arround.
(Side note I may should've keept Y unfrozen for the case that I at some point want a stunned enemy to fall down.)
If anyone of you want to use Freez Rigidbody in your FSM as well here is the code:
PS: Yes the code needed to be that long because Rigidbody simply works that way. I wished it wasn't that strange because it would've saved me generating all 64 different version a RigidbodyConstrain can have.
If Anyone wondered how I did it. I wrote a code were I was able to set the different bools and generate a text that included the right if statement together with the right RigidbodyConstrant options. only problem was the text was generated with a "|;}" at the end but needed only ";}"
I hope you guys find good use for this.
Writing the text generating code took me about an hour because I needed to check if it was generated right. And then I needed to copy all the different results into my code. I also tried to order them by certain criteria to prevent the script to actually go through 64 different If Statements.
My Solution was a new FSM Action which costed quite some time to write down. I freezed all Rigidbody constrains while my enemy was stunned which made my player stop draging it arround.
(Side note I may should've keept Y unfrozen for the case that I at some point want a stunned enemy to fall down.)
If anyone of you want to use Freez Rigidbody in your FSM as well here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Invector.vCharacterController.AI.FSMBehaviour
{
#if UNITY_EDITOR
[vFSMHelpbox("This Script copies the exact true or false values of the Positions and Roations to the Rigidbody. If a bool a false the Rigidbody Constrain will be unfrozen.",UnityEditor.MessageType.Info)]
#endif
public class FreezeRigidbodyConstrains : vStateAction
{
public override string defaultName
{
get
{
return "Freeze Rigidboy";
}
}
public FreezeRigidbodyConstrains()
{
executionType = vFSMComponentExecutionType.OnStateEnter;
FreezePositionX = false;
FreezePositionY = false;
FreezePositionZ = false;
FreezeRotationX = false;
FreezeRotationY = false;
FreezeRotationZ = false;
}
public bool FreezePositionX;
public bool FreezePositionY;
public bool FreezePositionZ;
public bool FreezeRotationX;
public bool FreezeRotationY;
public bool FreezeRotationZ;
public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate)
{
if (executionType == vFSMComponentExecutionType.OnStateEnter) {
// if (!IgnorePosition || !IgnoreRotation) {
Rigidbody RBody = fsmBehaviour.aiController.gameObject.GetComponent<Rigidbody> ();
//63Freez All
if (FreezePositionX && FreezePositionY && FreezePositionZ && FreezeRotationX && FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
//64UnfreezAll
} else if (!FreezePositionX && !FreezePositionY && !FreezePositionZ && !FreezeRotationX && !FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.None;
//All ___xyz Versions (7)
} else if (!FreezeRotationX && !FreezeRotationY && !FreezeRotationZ) {
//1Xyzxyz
if (FreezePositionX && !FreezePositionY && !FreezePositionZ && !FreezeRotationX && !FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX;
}
//2xYzxyz
if (!FreezePositionX && FreezePositionY && !FreezePositionZ && !FreezeRotationX && !FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionY;
}
//3xyZxyz
if (!FreezePositionX && !FreezePositionY && FreezePositionZ && !FreezeRotationX && !FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionZ;
}
//4xYZxyz
if (!FreezePositionX && FreezePositionY && FreezePositionZ && !FreezeRotationX && !FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ;
}
//5XyZxyz
if (FreezePositionX && !FreezePositionY && FreezePositionZ && !FreezeRotationX && !FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ;
}
//6XYzxyz
if (FreezePositionX && FreezePositionY && !FreezePositionZ && !FreezeRotationX && !FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY;
}
//7XYZxyz
if (FreezePositionX && FreezePositionY && FreezePositionZ && !FreezeRotationX && !FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ;
}
//All xyz___Version (7)
} else if (!FreezePositionX && !FreezePositionY && !FreezePositionZ) {
//8xyzXYZ
if (!FreezePositionX && !FreezePositionY && !FreezePositionZ && FreezeRotationX && FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
}
//9xyzXyz
if (!FreezePositionX && !FreezePositionY && !FreezePositionZ && FreezeRotationX && !FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezeRotationX;
}
//10xyzxYz
if (!FreezePositionX && !FreezePositionY && !FreezePositionZ && !FreezeRotationX && FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezeRotationY;
}
//11xyzxyZ
if (!FreezePositionX && !FreezePositionY && !FreezePositionZ && !FreezeRotationX && !FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezeRotationZ;
}
//12xyzxYZ
if (!FreezePositionX && !FreezePositionY && !FreezePositionZ && !FreezeRotationX && FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
}
//13xyzXyZ
if (!FreezePositionX && !FreezePositionY && !FreezePositionZ && FreezeRotationX && !FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
}
//14xyzXYz
if (!FreezePositionX && !FreezePositionY && !FreezePositionZ && FreezeRotationX && FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY;
}
//All XYZ___ || ___XYZ Versions
} else if (FreezePositionX && FreezePositionY && FreezePositionZ || FreezeRotationX && FreezeRotationY && FreezeRotationZ) {
//All XYZ___ Versions (6)
if (FreezePositionX && FreezePositionY && FreezePositionZ) {
//15XYZxyZ
if (FreezePositionX && FreezePositionY && FreezePositionZ && !FreezeRotationX && !FreezeRotationY && FreezeRotationZ)
{RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationZ;}
//16XYZXyz
if (FreezePositionX && FreezePositionY && FreezePositionZ && FreezeRotationX && !FreezeRotationY && !FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX;}
//17XYZxYz
if (FreezePositionX && FreezePositionY && FreezePositionZ && !FreezeRotationX && FreezeRotationY && !FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationY;}
//18XYZxYZ
if (FreezePositionX && FreezePositionY && FreezePositionZ && !FreezeRotationX && FreezeRotationY && FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;}
//19XYZXyZ
if (FreezePositionX && FreezePositionY && FreezePositionZ && FreezeRotationX && !FreezeRotationY && FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;}
//20XYZXYz
if (FreezePositionX && FreezePositionY && FreezePositionZ && FreezeRotationX && FreezeRotationY && !FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY;}
// ___XYZ Versions (6)
} else if (FreezeRotationX && FreezeRotationY && FreezeRotationZ) {
//21XYzXYZ
if (FreezePositionX && FreezePositionY && !FreezePositionZ && FreezeRotationX && FreezeRotationY && FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;}
//22XyZXYZ
if (FreezePositionX && !FreezePositionY && FreezePositionZ && FreezeRotationX && FreezeRotationY && FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;}
//23xYZXYZ
if (!FreezePositionX && FreezePositionY && FreezePositionZ && FreezeRotationX && FreezeRotationY && FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;}
//24xyZXYZ
if (!FreezePositionX && !FreezePositionY && FreezePositionZ && FreezeRotationX && FreezeRotationY && FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;}
//25xYzXYZ
if (!FreezePositionX && FreezePositionY && !FreezePositionZ && FreezeRotationX && FreezeRotationY && FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;}
//26XyzXYZ
if (FreezePositionX && !FreezePositionY && !FreezePositionZ && FreezeRotationX && FreezeRotationY && FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;}
}
} else {
if (FreezePositionX && FreezeRotationX || FreezePositionY && FreezeRotationY || FreezePositionZ && FreezeRotationZ) {
//X__X__ (7)+(2)
if (FreezePositionX && FreezeRotationX) {
//27XYzXYz
if (FreezePositionX && FreezePositionY && !FreezePositionZ && FreezeRotationX && FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY;
}
//28XyZXyZ
if (FreezePositionX && !FreezePositionY && FreezePositionZ && FreezeRotationX && !FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
}
//29XYzXyz
if (FreezePositionX && FreezePositionY && !FreezePositionZ && FreezeRotationX && !FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationX;
}
//30XyzXyz
if (FreezePositionX && !FreezePositionY && !FreezePositionZ && FreezeRotationX && !FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezeRotationX;
}
//31XyzXYz
if (FreezePositionX && !FreezePositionY && !FreezePositionZ && FreezeRotationX && FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY;
}
//32XyZXyz
if (FreezePositionX && !FreezePositionY && FreezePositionZ && FreezeRotationX && !FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX;
}
//33XYzXyZ
if (FreezePositionX && FreezePositionY && !FreezePositionZ && FreezeRotationX && !FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
}
//34XyZXYz
if (FreezePositionX && !FreezePositionY && FreezePositionZ && FreezeRotationX && FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY;
}
//35XyzXyZ
if (FreezePositionX && !FreezePositionY && !FreezePositionZ && FreezeRotationX && !FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
}
//_Y__Y_ (7)+(1)
} else if (FreezePositionY && FreezeRotationY) {
//36xYZxYZ
if (!FreezePositionX && FreezePositionY && FreezePositionZ && !FreezeRotationX && FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
}
//37xYzxYz
if (!FreezePositionX && FreezePositionY && !FreezePositionZ && !FreezeRotationX && FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationY;
}
//38XYzxYz
if (FreezePositionX && FreezePositionY && !FreezePositionZ && !FreezeRotationX && FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationY;
}
//39xYzxYZ
if (!FreezePositionX && FreezePositionY && !FreezePositionZ && !FreezeRotationX && FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
}
//40xYzXYz
if (!FreezePositionX && FreezePositionY && !FreezePositionZ && FreezeRotationX && FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY;
}
//41xYZxYz
if (!FreezePositionX && FreezePositionY && FreezePositionZ && !FreezeRotationX && FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationY;
}
//42xYZXYz
if (!FreezePositionX && FreezePositionY && FreezePositionZ && FreezeRotationX && FreezeRotationY && !FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY;
}
//43XYzxYZ
if (FreezePositionX && FreezePositionY && !FreezePositionZ && !FreezeRotationX && FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
}
//__Z__Z (7)
} else if (FreezePositionZ && FreezeRotationZ) {
//44xyZxyZ
if (!FreezePositionX && !FreezePositionY && FreezePositionZ && !FreezeRotationX && !FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationZ;
}
//45xyZxYZ
if (!FreezePositionX && !FreezePositionY && FreezePositionZ && !FreezeRotationX && FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
}
//46xyZXyZ
if (!FreezePositionX && !FreezePositionY && FreezePositionZ && FreezeRotationX && !FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
}
//47xYZXyZ
if (!FreezePositionX && FreezePositionY && FreezePositionZ && FreezeRotationX && !FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
}
//48XyZxyZ
if (FreezePositionX && !FreezePositionY && FreezePositionZ && !FreezeRotationX && !FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationZ;
}
//49xYZxyZ
if (!FreezePositionX && FreezePositionY && FreezePositionZ && !FreezeRotationX && !FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationZ;
}
//50XyZxYZ
if (FreezePositionX && !FreezePositionY && FreezePositionZ && !FreezeRotationX && FreezeRotationY && FreezeRotationZ) {
RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
}
}
} else {
//51XYzxyZ
if (FreezePositionX && FreezePositionY && !FreezePositionZ && !FreezeRotationX && !FreezeRotationY && FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationZ;}
//52xYZXyz
if (!FreezePositionX && FreezePositionY && FreezePositionZ && FreezeRotationX && !FreezeRotationY && !FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX;}
//53XyzxYZ
if (FreezePositionX && !FreezePositionY && !FreezePositionZ && !FreezeRotationX && FreezeRotationY && FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;}
//54xYzXyZ
if (!FreezePositionX && FreezePositionY && !FreezePositionZ && FreezeRotationX && !FreezeRotationY && FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;}
//55xyZXYz
if (!FreezePositionX && !FreezePositionY && FreezePositionZ && FreezeRotationX && FreezeRotationY && !FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY;}
//56XyZxYz
if (FreezePositionX && !FreezePositionY && FreezePositionZ && !FreezeRotationX && FreezeRotationY && !FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationY;}
//57xyZxYz
if (!FreezePositionX && !FreezePositionY && FreezePositionZ && !FreezeRotationX && FreezeRotationY && !FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationY;}
//58XyzxyZ
if (FreezePositionX && !FreezePositionY && !FreezePositionZ && !FreezeRotationX && !FreezeRotationY && FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezeRotationZ;}
//59XyzxYz
if (FreezePositionX && !FreezePositionY && !FreezePositionZ && !FreezeRotationX && FreezeRotationY && !FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezeRotationY;}
//60xYzXyz
if (!FreezePositionX && FreezePositionY && !FreezePositionZ && FreezeRotationX && !FreezeRotationY && !FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationX;}
//61xYzxyZ
if (!FreezePositionX && FreezePositionY && !FreezePositionZ && !FreezeRotationX && !FreezeRotationY && FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationZ;}
//62xyZXyz
if (!FreezePositionX && !FreezePositionY && FreezePositionZ && FreezeRotationX && !FreezeRotationY && !FreezeRotationZ) {RBody.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX;}
}
}
}
}
}
}
PS: Yes the code needed to be that long because Rigidbody simply works that way. I wished it wasn't that strange because it would've saved me generating all 64 different version a RigidbodyConstrain can have.
If Anyone wondered how I did it. I wrote a code were I was able to set the different bools and generate a text that included the right if statement together with the right RigidbodyConstrant options. only problem was the text was generated with a "|;}" at the end but needed only ";}"
I hope you guys find good use for this.
Writing the text generating code took me about an hour because I needed to check if it was generated right. And then I needed to copy all the different results into my code. I also tried to order them by certain criteria to prevent the script to actually go through 64 different If Statements.