Door automatically open/close

How can I make it so a door will open then when you get so far away from it it will close? I’ve tried proximity but it doesn’t close the door again, and I’ve tried raycasts.

Smart people that might have an answer

@CodeAlpaca, @Galactian, @DeadlyGumChewer

2 Likes

Use the “In View” behavior, it’s at the very bottom of the Triggers list.

1 Like

Use a proximity looking for the player and a NOR logic gate.

1 Like

If you want the door to still be on screen and close do what Galactian said. You can also get the X and Y and use the distance equation to figure out how far the player is (The reason to use this would be if it had a slight effect on performance)

1 Like

Ok, thank you that worked never used logic gates before so it didn’t come to mind. :laughing:

1 Like

I’d recommend using the distance formula since it’s not simulating an entire proximity which makes it way less laggy.

1 Like
{"data":{"behavior":{"v":"2","nodes":[{"inputCount":2,"outputCount":1,"name":"Distance","behaviorType":"logic.NodeGroup","x":90,"y":32,"id":"295f1ca065d56c49","notes":"Non-Physics Proximity","n_o":0,"isMenuItem":false},{"expression":"b-a","default0":0,"default1":0,"default2":0,"default3":0,"default4":0,"default5":0,"params":2,"version":1,"tag":"","inputCount":3,"outputCount":1,"name":"Expression","behaviorType":"logic.logic.Expression","x":270,"y":224,"group":"295f1ca065d56c49","id":"295f1ca32dd6e44b"},{"expression":"b-a","default0":0,"default1":0,"default2":0,"default3":0,"default4":0,"default5":0,"params":2,"version":1,"tag":"","inputCount":3,"outputCount":1,"name":"Expression","behaviorType":"logic.logic.Expression","x":270,"y":96,"group":"295f1ca065d56c49","id":"295f1ca4f81f7247"},{"inputCount":0,"outputCount":1,"name":"Always","behaviorType":"logic.triggers.Always","x":-270,"y":64,"group":"295f1ca065d56c49","id":"295f1ca4f4b01f43"},{"expression":"Math.sqrt(Math.abs(A*A) + Math.abs(B*B))","default0":0,"default1":0,"default2":0,"default3":0,"default4":0,"default5":0,"params":2,"version":1,"tag":"","inputCount":3,"outputCount":1,"name":"Expression","behaviorType":"logic.logic.Expression","x":450,"y":160,"group":"295f1ca065d56c49","id":"295f1ca6f1e1cf4a"},{"inputCount":1,"outputCount":1,"name":"Extractor","behaviorType":"logic.properties.Extractor","x":-90,"y":128,"group":"295f1ca065d56c49","id":"295f1ca6969a8049","targetId":0,"prop":"y"},{"inputCount":1,"outputCount":1,"name":"Extractor","behaviorType":"logic.properties.Extractor","x":-90,"y":32,"group":"295f1ca065d56c49","id":"295f1ca73feff14f","targetId":0,"prop":"x"},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":-90,"y":224,"group":"295f1ca065d56c49","id":"295f1ca7416bce47","portId":"295f1ca065d56c49i0","tag":"X","dataType":2},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":-90,"y":320,"group":"295f1ca065d56c49","id":"295f1ca72d496b48","portId":"295f1ca065d56c49i1","tag":"Y","dataType":2},{"inputCount":1,"outputCount":0,"name":"Bundle Output","behaviorType":"logic.NodeGroupOutput","x":630,"y":160,"group":"295f1ca065d56c49","id":"295f1ca7d946424a","portId":"295f1ca065d56c49o0","tag":"Pixels","dataType":2}],"links":[{"input_id":"295f1ca6f1e1cf4ai1","output_id":"295f1ca32dd6e44bo0"},{"input_id":"295f1ca6f1e1cf4ai2","output_id":"295f1ca32dd6e44bo0"},{"input_id":"295f1ca6f1e1cf4ai0","output_id":"295f1ca4f81f7247o0"},{"input_id":"295f1ca73feff14fi0","output_id":"295f1ca4f4b01f43o0"},{"input_id":"295f1ca6969a8049i0","output_id":"295f1ca4f4b01f43o0"},{"input_id":"295f1ca7d946424ai0","output_id":"295f1ca6f1e1cf4ao0"},{"input_id":"295f1ca32dd6e44bi0","output_id":"295f1ca6969a8049o0"},{"input_id":"295f1ca4f81f7247i0","output_id":"295f1ca73feff14fo0"},{"input_id":"295f1ca4f81f7247i1","output_id":"295f1ca7416bce47o0"},{"input_id":"295f1ca4f81f7247i2","output_id":"295f1ca72d496b48o0"},{"input_id":"295f1ca32dd6e44bi1","output_id":"295f1ca72d496b48o0"},{"input_id":"295f1ca32dd6e44bi2","output_id":"295f1ca72d496b48o0"}]}}}

distance formula

1 Like

Wow, I didn’t know I was smart, you can use raycasts and do animations and with enables to.

1 Like