Product Chat (Early Access) / [SOLVED] Destroy entity with trigger zone in Max?

Author
Message
mguy1122
Game Guru Backer
12
Years of Service
User Offline
Joined: 5th Mar 2013
Playing: witcher 3
Posted: 27th Apr 2022 00:32
I'm doing a little haunted house test level for practice and figuring out how the new trigger zones work . making stuff appear with the trigger zone is pretty easy but how would I get something to disappear via a trigger zone? what I'm trying to make happen is if the player goes into the kitchen and returns to the dining room the chairs around the table will disappear and a new set will appear on top of the table like in the movie poltergeist. can you do this currently or does it require a custom script? any help will be appreciated, thanks

The author of this post has marked a post as an answer.

Go to answer
PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 27th Apr 2022 15:33
Show(e) makes things appear
Hide(e) does the opposite.

Since you are going to use a trigger most likely you will need the entity ID, so, if your entity id is let's say 8 then rather than Hide(e) it would be Hide(8); anyway, it is not the best due it might change along with the game development; so, the best way is using the entity name.

Quote: "for k,v in pairs(g_Entity) do
if GetEntityName(k) == "Your entity name goes here" then
Hide(k) -- or Show(k) depending what you want to do
break
end
end"


Of course no the whole script, but can give you an idea.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
mguy1122
Game Guru Backer
12
Years of Service
User Offline
Joined: 5th Mar 2013
Playing: witcher 3
Posted: 27th Apr 2022 16:05 Edited at: 27th Apr 2022 16:06
Thanks for the reply, that makes sense. I found a script for the original game guru that does what I want but I wasn't sure it would even work with Max because of the different structure. Some of my other scripts I was using didn't work. So at least for now this script should work to get me to where I want to go? I change the [E] to [chair] for my specific idea for the object name.

function plrinzone_init(e)
end
function plrinzone_main(e)
if g_Entity[e]['plrinzone']==1 then
Destroy(chair) -- change the 1 to the entity # of the object you want to hide
PlaySound(e,0)
Destroy(e)
ActivateIfUsed(e)
end
end
PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 27th Apr 2022 18:33 Edited at: 27th Apr 2022 18:34
This post has been marked by the post author as the answer.
Quote: "Destroy(chair)"

It does not work like so; try my chunk of code inside your script.
It should look like the one below:

Quote: "function plrinzone_init(e)
end

function plrinzone_main(e)
if g_Entity[e]['plrinzone']==1 then
for k,v in pairs(g_Entity) do
if GetEntityName(k) == "Your entity name goes here" then
Hide(k) -- or Show(k) depending what you want to do
end
end
PlaySound(e,0)
Destroy(e)
ActivateIfUsed(e)
end
end"


Note: Code tags are not working for me, so, I'm quoting the code.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
mguy1122
Game Guru Backer
12
Years of Service
User Offline
Joined: 5th Mar 2013
Playing: witcher 3
Posted: 27th Apr 2022 22:41
That seemed to do the trick, thanks! The script wasn't showing up at first but I found out you need a description at the top for it to be visible in Max. Anyway, this should do nicely for my scene. Thanks again for your help 3com!
PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 28th Apr 2022 01:26
Glad to help
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
lordjulian
11
Years of Service
User Offline
Joined: 10th Jan 2014
Location:
Posted: 30th Apr 2022 00:20
Can this be done with visual logic?
Julian - increasingly disillusioned and jaded
PM
mguy1122
Game Guru Backer
12
Years of Service
User Offline
Joined: 5th Mar 2013
Playing: witcher 3
Posted: 6th May 2022 00:42 Edited at: 6th May 2022 00:45
Well, I hit a little snag with this script. It works great when the map isn't populated but once you start putting trigger zones and other things all of the place for some reason the script stops working which is kind of strange. Any reason the other zones might be messing with this? i managed to bypass the problem of getting my chairs to disappear by just having them fly out the level with the sliding door script but this script seems much cleaner to get things done
PM

Login to post a reply

Server time is: 2025-03-12 04:24:07
Your offset time is: 2025-03-12 04:24:07