lowering doors, and sinking alters?

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
LunasC
Posts: 38
Joined: Sun Feb 10, 2013 1:46 pm

lowering doors, and sinking alters?

Post by LunasC »

I am trying to get an alter to sink into the ground when triggered. I used some of the script for a door but I cannot for the life of me seem to make it go down into the floor.
Everything I have tried has led me to either a glitch or an alter rising to the ceiling.
Any help would be great as I am losing my mind here.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: lowering doors, and sinking alters?

Post by minmay »

If you want it to function like a door then you need to edit the model so it has a gate node (look at the door models in the standard assets for examples). Non-double doors always open upwards, so you would need to start it opened instead of closed. Of course, you'll have to separate the model and door components into a different object if you want to do this, because trying to use a DoorComponent and a SurfaceComponent/ObstacleComponent on the same object is just not going to work. Note: this approach is a really bad idea.

A better approach is to call GameObject:setWorldPositionY() every frame. (To run code on every frame, just add a TimerComponent to the party object with a very small interval like 0.0001; TimerComponents only trigger a maximum of once per frame, so the result is that its onActivate hook will be called once every frame). You will need to move any items on the surface as well as the altar though.

You could also make an animation for it, but it's easier to just change the world position every frame. No matter what approach you use, you'll have to do something about the items on the altar.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: lowering doors, and sinking alters?

Post by Azel »

LunasC wrote:I am trying to get an alter to sink into the ground when triggered. I used some of the script for a door but I cannot for the life of me seem to make it go down into the floor.
Everything I have tried has led me to either a glitch or an alter rising to the ceiling.
Any help would be great as I am losing my mind here.
Here ya go: http://mystrock.com/files/AltarFun.zip

Lowers an Altar in to the dungeon floor (through a trap door). And then raises it back out. Hope it helps! :mrgreen:
Post Reply