Hi.
I have simple question. How to detect if object goes up or down.
my script is wrong and I need some one to correct it.
What exactly are you trying to do? Your original question is quite vague so there can be a number of different things we can do. Your script looks fine to me so I don't know what else you're looking for.
jgonzalez ,OK. I will tell you why it's wrong. If you look at my script line 10 [ if (dis >10) ] is working. if dis value is 5, detector will be true. if value goes down to 4 it should be False not true. Even if value under 0. That's what i want to do, but i don't know how ?
aaeleas So you want to check to see if it moved down based off its last state. In that case you want to update the distance every time it moves. You also want to reset the current position otherwise it will never detect when you move down unless you pass the original distance of where the object was last.
Here is an example https://pastebin.com/Jj2AQsvh
Note this checks against the last and current position of the object that has this script. It's not check the distance between two separate objects. If you had two objects that were moving together you could modify the script to use both objects.
The threshold determines when it should check if the distance is greater than or less than to determine if it has moved up or down. By default it is set at 0, so any movement up or down will then trigger it to toggle the bool.
jgonzalez , you legend. I don't know what to say....Thank you so much JG.