Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: SawyerK on May 25, 2020, 07:41:23 AM
-
Hi!
I have a rigidbody object that needs to send an event when it turns upside down.
How do i check if the object is upside down? I tried Get Rotation and Get Vector XYZ
but it doesn't seem to work with the Float Sign Test IsPositive/IsNegative event. I don't even know where to begin with this.
-
Heya,
Rotation would be the best bet I can think for this. Simply just grab the rotation at the start and then check when it moves if it equals original +180 (-180 in case it goes the other way as well).
-
Vectors often need to be converted to their individual floats to check them. There are actions for this, too, usually stuff like VectorXY/Z. Once you extracted the value you want to check, e.g. the rotated axis, you can check it e.g. with float compare.
-
The problem is that the rotation is 0 to 360. There is no negative (-180). How do i get the negative value?
-
The problem is that the rotation is 0 to 360. There is no negative (-180). How do i get the negative value?
You rotate your object in the inspector to the position that you think qualifies as “upside down”, then you note down the rotation values or range, which axis and so on. Then, put everything back how it was and use an FSM to check those conditions at runtime.
This method is generally very useful: before you implement or automate anything, test the steps “by hand”. Then you have a good idea what exactly needs to happen and it’s easier to implement.
-
The floats and angles are all over the place cant use float compare with this method.
-
"The floats and angles are all over the place…"
You need an independent gameobject in your scene that is oriented 'up' as a worldspace reference to compare to.
-
Object orientation check? Super easy.
Use 'Transform Direction', set the gameobject you want to check as the specified gameobject, and set the local direction Y to 1.
You should now get the 'normals' of the object in world space. If its upside down, the returned Y value of the 'Vector 3' variable will be -1.
-
WOW nuFF3 this is exactly what i needed, thank you very much! :D