Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make Objects de-spawn (disappear).
Simpanra Offline
Senior Member

Posts: 314
Threads: 28
Joined: Mar 2011
Reputation: 0
#1
How to make Objects de-spawn (disappear).

Ok, so this is what im aiming to achieve;

you press a switch in room A,
In room B a pair of book shelves swing open to reveal a hidden passage (i want to do this by making the bookshelves de-spawn where they are currently and make similar ones appear in the open position, im want to do this because the bookshelves are full and so it would be too hard for me to tell them to swivel on their axis.)

However, after trying to use a SetEntityActive("shelves", false); function only some of the items de-spawned. After looking closer at the items that did de-spawn i realised they were all forms of intractable entities, whereas the ones that remained in their place were all static (for example, they came from the entity tabs; ornament, storage and desktop.)

Does anybody know a script that will de-spawn items such as these?

Thanks =)

Edd,
05-06-2011, 04:33 PM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#2
RE: How to make Objects de-spawn (disappear).

So you want to de-activate every item on a bookshelf and the bookshelf - then activate another one, but stuff like shelves won't disappear? You might want to consider making a new secret shelf entity if this is the case (don't worry about making it a proper move-object or anything - using the rotate property (and disabling the move and center) properties of a sticky area can create the same effect. This would be faster and easier than naming all the objects according to a pattern and de-activating and activating in a loop based on that pattern - i can mock up a script for this if you want though.
(This post was last modified: 05-06-2011, 04:42 PM by Apjjm.)
05-06-2011, 04:36 PM
Find
Simpanra Offline
Senior Member

Posts: 314
Threads: 28
Joined: Mar 2011
Reputation: 0
#3
RE: How to make Objects de-spawn (disappear).

(05-06-2011, 04:36 PM)Apjjm Wrote: So you want to de-activate every item on a bookshelf and the bookshelf - then activate another one, but stuff like shelves won't disappear? You might want to consider making a new secret shelf entity if this is the case, as doing so would be faster and easier than naming all the objects according to a pattern and de-activating and activating in a loop based on that pattern - i can mock up a script for this if you want though.

Wow that would be brilliant =D And what do you mean by a secret shelf entity? =) thank you so much for such a swift and informative response =)

Edd,
05-06-2011, 04:43 PM
Find
dragonlordsd Offline
Member

Posts: 112
Threads: 7
Joined: May 2011
Reputation: 0
#4
RE: How to make Objects de-spawn (disappear).

You know, I'm not sure quite how the physics would work with moving shelves with objects on them, but it might create a really neat effect if the objects on the shelves realistically tumbeld off and stuff when they moved. In that case, it might be cool just to have the shelves swivel in place.
Then and again... I've never tried something like that, so I really have no idea how that would work.
05-06-2011, 04:45 PM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#5
RE: How to make Objects de-spawn (disappear).

(05-06-2011, 04:43 PM)Simpanra Wrote: Wow that would be brilliant =D And what do you mean by a secret shelf entity? =) thank you so much for such a swift and informative response =)

Edd,

Edit: Ignore what was here before, easier way:

Give your items and (new) shelf entities to deactivate the following prefix in the editor "shelfDeactivateObjects_" and the ones to activate "shelfActivateObjects_". E.g: "shelfActivateObjects_book_1". Then you can add:
void iWantToMoveMyShelf() {
SetEntityActive("shelfDeactivateObjects_*",false);
SetEntityActive("shelfActivateObjects_*",true);
}
However, your static shelf won't disappear yet with this approach. So you will need to make a new entity (copy the old shelf's entity file) and change it so it is a 0-mass (or very large mass) object so other objects can't push it. Then go into Settings->UserDefinedVars in the model editor, and make it of type "object" and subtype "static" - make sure the body name (not mesh name!) is entered into the "mainPhysicsBody" field (probably called "Body_1"). Replace your old shelf with this new shelf.

If you are going to all this trouble though, it may be easier to just go and make a proper custom shelf entity with the books and stuff on it (you can make it static then), and use a sticky area to rotate it.
(This post was last modified: 05-06-2011, 05:31 PM by Apjjm.)
05-06-2011, 05:04 PM
Find
Simpanra Offline
Senior Member

Posts: 314
Threads: 28
Joined: Mar 2011
Reputation: 0
#6
RE: How to make Objects de-spawn (disappear).

0_0 thats....complex...
05-06-2011, 05:38 PM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#7
RE: How to make Objects de-spawn (disappear).

(05-06-2011, 05:38 PM)Simpanra Wrote: 0_0 thats....complex...

This should guide you through it:

Setting up the new entity:
In this example i am using "shelf2", but you might be using a different shelf. The process should be the same.
This approach assumes you don't want to use the "secret_shelf" entity, and can't / don't want to make a custom "secret_shelf".
Open up your model editor, and find the shelf file you are using. Shelves are in the found folder entities/storage. Load in the shelf you want to make activate-able, and choose save-as:
http://imgur.com/KcEEG

Call the shelf something different, in this example it is called shelf02_Activateable.
Now that we aren't working on the original, it is time to change some settings! First select the boxy green mesh around the object, and make sure the settings window has the mass set to 0 and the body name (in the general tab) as "Body_1":
http://imgur.com/pu31Y

Now look at the top bar, and select Settings->UserDefinedVariables and change the settings from "static prop" to the ones shown in the below image. Make sure to enter "Body_1" in the shown place!
http://imgur.com/hLxAN

Save, and exit the model editor, we should be done with that now!

Setting up the map
Now we finally can replace the shelf in the map. Open up the level editor and select the shelf you wish to replace, and find the entity file box in the "general" tab.
http://imgur.com/4QqW5

Click the "..." and navigate and load your custom entity:
http://i.imgur.com/vPgLa.png

Do these last two steps for each shelf you want to be able to toggle the activate property of. Now make sure all the instances in your map you wish to deactivate as part of this effect have the prefix "shelfDeactivateObjects_", and those you wish to activate "shelfActivateObjects_". In one of the screenshots above you will see I called my shelf "shelfDeactivateObjects_Shelf", as long as the correct prefix is there it doesn't matter what goes after the underscore.


Finally, in your script file, where you want to make the objects disappear, place in the following two lines of code:
SetEntityActive("shelfDeactivateObjects_*",false);
SetEntityActive("shelfActivateObjects_*",true);

This isn't overly difficult to do, but it is quite a bit of work.
(This post was last modified: 05-06-2011, 06:09 PM by Apjjm.)
05-06-2011, 06:07 PM
Find
user1220 Offline
Junior Member

Posts: 1
Threads: 0
Joined: Apr 2012
Reputation: 0
#8
RE: How to make Objects de-spawn (disappear).

Hi, thanks for this detailed explanation. I tried to do something similar, a wall that disappears in order to reveal a secret passage, and its working great so far. The only problem is that I can walk through the wall, even if it is visible. The player doesn't seem to collide with my wall entity. I couldn't find any option in the material editor to enable collision, and changing the object to static_physics in the level editor also didn't change anything.

Does someone know how I can fix this? I'd by grateful for any help. Smile

Thanks in advance!
(This post was last modified: 04-15-2012, 04:18 PM by user1220.)
04-15-2012, 04:17 PM
Find




Users browsing this thread: 4 Guest(s)