Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding open action to other objects #106

Open
he727425209 opened this issue Feb 14, 2019 · 3 comments
Open

adding open action to other objects #106

he727425209 opened this issue Feb 14, 2019 · 3 comments

Comments

@he727425209
Copy link

I noticed that objects such as microwave and cabinets have the action of opening, and I would love to add this open actions on other objects, such as doors. Right now I added the simobj id for the door, attached the door script to the door object, and tried to include the door simtype as part of the open_close state objects, but when I run the simulator and try to open the door, it doesn't work. Is there a way to make this happen?

@winthos
Copy link
Collaborator

winthos commented Feb 15, 2019

So even with the scripts and door simtype being updated, the Door itself doesn't have an animation to go with it to actually allow it to open. You need to create a new animation for the door and hook it up to the relevant scripts in the same way that Cabinets or Drawers are set up. It's best to find a Cabinet in scene and use that as reference to create a new Door animation.

@he727425209
Copy link
Author

I noticed that for the ToggleableAnimController, the On and Off all have None in their motion, I was wondering how were you able to make the door open and closed in the cabinet when there is no motion. As I saw a lot of tutorial videos, they all have motions inside their states. Also, in the Cabinet.cs, I notice that open = ParentObj.Animator.GetBool ("AnimState1");, but AnimState1 is not in the ToggleableAnimController, so where is it from?

@winthos
Copy link
Collaborator

winthos commented Feb 21, 2019

So turns out the Animator component is really just being used as a glorified bool check for if the Sim Object should be in state = open or state = closed, that's why there are no animations actually in the animator. The AnimState1 is a parameter on the Animator component which is on the ToggleableAnimController but it's kind of hidden behind the "Parameters" tab which is tiny and hard to find.

Ok, turns out there is a Door.cs script that you can make use of that should allow doors to be openable. There are quite a few steps to set this up:

First, find the Door Object in scene in the Hierarchy view. You want to create a New Empty Object and move it so that it is exactly where the Door's hinges would be, then name it something like "Door". This new Object will act as a pivot that is rotate to actually rotate the door about the correct axis.

screen shot 2019-02-21 at 10 19 17 am

screen shot 2019-02-21 at 10 20 21 am

Make sure this new Door empty is the parent of the door object that has all the collision and mesh components:

screen shot 2019-02-21 at 10 20 35 am

Now add the Door.cs component to the Door object, and you should start getting some warnings. Click and drag the Door object into the pivot field of the Door Component, then set the open/close rotations as appropriate. You will need to change the open/close rotations depending on the facing of the door because they are in world coordinates.

screen shot 2019-02-21 at 10 20 57 am

After that, go into the SimObjType.cs script and make sure to add "Door" to the SimObjType enum found in that script:

screen shot 2019-02-21 at 10 32 08 am

Now go back to the editor and find the SimObj component on the door. Set the Object Type as "Door" and set the manipulation type as "static." Then make sure to run the scene once so that the Unique ID can be generated. At the end your door object should look something like this:

screen shot 2019-02-21 at 10 22 08 am

Do note that opening doors set up in this way will allow the Agent to get out of bounds of the room, and also the "visibility" of the doors might be inconsistent due to the way that the raycast to check a Sim Object's visibility works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants