Dynamic Property Set Value: Why this formula does'nt works?

I’m building a “Door” Prototype. Inside there’s a dynamic property called “DoorStatus”, which represent the … well… door status :smiley:

0 means the door is closed
1 means the door is open
2 means the door is destroyed.

So my DoorStatus dynamic property is configured this way:

Name: DoorStatus Value: 0 Is Numeric: CHECK Min: 0 Max: 2 Wrap: UNCHECK

I want to switch from 0 to 1 and viceversa with the same key command, but do nothing if the door is destroyed.
So i’ve made a Open / Close command that set value directly with this expression in the New value field:


To me, this line means that
if DoorStatus is 0, it returns 1
else if DoorStatus is 1, it returns 0
else it returns the current value of DoorStatus (so, not changing it).

But this does’nt works; when i give the key command:
if DoorStatus is 0, it becomes 1 (and this is ok)
if DoorStatus is 1, it remains[b] 1 /b
if DoorStatus is 2, it becomes [b]1 /b

The same expression put in a calculated property (NextDoorStatus) works as expected.

Why i don’t get the expected results and instead it always returns 1?

Hi, when you place DoorStatus before the == symbol, it’s interpreted and calculated.
When you place it as a value, for your last assigned else, it’s treated as … text ! try by encapsulating the last between $$ so it will be interpreted :