Reputation: 593
I have 10 Capsules in my game.
I want to check if those Capsules are standing like they do when the game starts, or if they are fallen down (laying on the ground).
What i would need is:
But i don't know how to do that?!
Upvotes: 1
Views: 59
Reputation: 20269
Vector3.Angle(gameObject.transform.up, Vector3.up)
Compare the output of Vector3.Angle(gameObject.transform.up, Vector3.up)
to a limit, and see if the angle exceeds (or meets?) that limit.
GameObject gameObject; // given
float angleLimit; // given - measured in degrees
float upAngle = Vector3.Angle(gameObject.transform.up, Vector3.up);
if (upAngle >= angleLimit) {
// gameObject is not upright
}
Upvotes: 1