Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > CopperCube Open discussion
Opening/Closing door

joma_ch
Registered User
Quote
2011-10-23 00:11:29

Hey everyone!

I have a small question. Is it possible to make a door open if you click it, and then close it if you click it again, without any scripting, and only by using the behavior-options?
I have tried for a couple of hours, but I can't get my head around it.

thx



erik
Registered User
Quote
2011-10-23 06:56:14

I'd say there are multiple ways of doing it. You could do it using an animation, or maybe using a rotation or move behavior. Either way, if you click it once, move it or animate it, and set a variable named for example 'DoorClosed' to 1. And in your action, do the one animation only if the Variable is null, and the other one if the variable is 1.
Automatic doors (without clicking) are a bit simpler. You can use a 'On Proximity' behavior for this.


joma_ch
Registered User
Quote
2011-10-23 19:34:56

Thx for the reply. I have actually tried for a couple of hours to rotate the door using behaviours and variables, but I'm not able to solve my problem. Think I've just got stuck.
I'm able to make the door open and close one time, but thats it. I would like it to be dynamic, so that the door can be opened and closed infinite times. It might be simple, but I can't really figure it out.
If its possible, could someone please give me a step-by-step instruction? Would really appreciate it


*EDIT*


Wow, just got it working! If anyone else is wondering how to do this, just ask and ill try to explain


magic
Registered User
Quote
2011-10-23 21:15:35

Yes, please share your knowledge


joma_ch
Registered User
Quote
2011-10-24 20:05:03

Allrighty... Here's all the steps:

With the door selected, add the behaviour "When clicked on this do something":

In Action, add "If a variable has a value, do something":
- Give it a variable name, I'll use "Door"
- Use "Is equal to"
- Value: "null"
-- In action, add "Change rotation of a scene node", and rotate the door as much as you want (this is the open door-animation).
-- Also add "Set or Change a Variable",
-- Variable name: "Door"
-- Operation "Add"
-- Value "1"

Then, go back to the actions for "When clicked on this do something" and add another "If a variable has a value, do something":
- Variable name: "Door"
- "Is equal to"
- Value: "2"
-- In action, add "Change rotation of a scene node", and rotate the door back to closed position (if you use absolute rotation, this should be 0,0,0)
-- Also add "Set or Change a Variable",
-- Variable name: "Door"
-- Operation: "Subtract"
-- Value: "2"


Then, again, add a third "If a variable has a value, do something":
- Variable name: "Door"
- "Is bigger than"
- Value: "0"
-- In action, add "Set or Change a Variable"
-- Variable name: "Door"
-- Operation: "Add"
-- Value: "1"


And you're done! Kind of repetitive, but it works... If you can't make it work, just ask!



*EDIT*

For some reason, I can only make this work in Windows Application, not in WebGL and Flash... Does anybody know why?


erik
Registered User
Quote
2011-10-25 15:08:14

wrote:
For some reason, I can only make this work in Windows Application, not in WebGL and Flash... Does anybody know why?


I think this is because you are testing against 'null'. Skip that part and initialize the variable to 1 or 0, so that you always only have it set to 0 or to 1.


joma_ch
Registered User
Quote
2011-10-25 20:43:57

wrote:

I think this is because you are testing against 'null'. Skip that part and initialize the variable to 1 or 0, so that you always only have it set to 0 or to 1.



Tried using a "0" instead of "null" now, but it still doesn't work.

Tried to add a door and just a single action to it: "When clicked on this do something" with "Change rotation of a scene node", and that works..

But, shouldn't this work? Doesn't both webGL and Windows Application use java?


niko
Moderator
Quote
2011-10-26 07:42:43

No, none of them use Java. Your problem is that the variable in the beginning is uninitialized, it has no value. What happens then is not defined. Simply set the variable to 1 or to 0 in the beginning of your scene by a different action, and it should work then.
Maybe adding some action to be able to initialize all used Variables easily to a certain value would be a nice addition for a future version..


joma_ch
Registered User
Quote
2011-10-26 09:37:38

wrote:
No, none of them use Java. Your problem is that the variable in the beginning is uninitialized, it has no value. What happens then is not defined. Simply set the variable to 1 or to 0 in the beginning of your scene by a different action, and it should work then.
Maybe adding some action to be able to initialize all used Variables easily to a certain value would be a nice addition for a future version..


Ah, okey, will try that!

Should have been possible to set variable values on scene start-up, that would definitely be a great feature!


crackyourspeaker
Registered User
Quote
2015-07-17 04:59:18

Yea I didn't know how to do that either, what I did was create a fake door on the wall, then added " to next scene" .. Then added a sound of opening and closing the door but build a scene for that room.. I mean yea its tacky I guess but it reminded me of the old resident evil games so I thought it was cool and its easy as well...


54newstar
Registered User
Quote
2015-07-24 00:29:02

my video here explains it:

https://www.youtube.com/watch?v=...


Ashden124
Guest
Quote
2021-03-06 08:38:57

so i did when clicked on this do something and then make the door rotate but it never updated the collision.


Robo
Guest
Quote
2021-03-06 13:30:02

If using physics need to use updateGeometry()

else try add a collide when moved around the door and player...should work..


Ashden124
Guest
Quote
2021-03-11 21:30:55

the only way i know you could do it is when clicked on do something and then do later and change the scene


mrbobs
Registered User
Quote
2024-03-06 23:53:01

joma_ch
how bro plus idk if u know how for this but i put my own door in cuppercube and it opens weird like full just turns 90 side ways open but other doors it opens normal. its like normal opens from one side and one it stuck on to wall and this one just turns kind of both it weird idk what to do


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internati?nal" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact