Using Models as Switch
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Using Models as Switch
So.... I have a small question here, and someone already probably did this.
Lets say that I have a MD3 model switch with 2 states ON/OFF
Whats the easiest way to set this model as a functional Switch?
Does anyone have a working example?
I will probably need some ZSCRIPT magic with this, not sure if this is possible in DECORATE
Thanks
Lets say that I have a MD3 model switch with 2 states ON/OFF
Whats the easiest way to set this model as a functional Switch?
Does anyone have a working example?
I will probably need some ZSCRIPT magic with this, not sure if this is possible in DECORATE
Thanks
Re: Using Models as Switch
Set it up as a switchable decoration with the +USESPECIAL flag? (should work in ZScript or DECORATE I think)
Re: Using Models as Switch
Wouldn't creating an actor, inheriting from SwitchableDecoration work?
I haven't used models before, but it's probably possible to play an animation in the Active state that ends with "Wait" keyword. (So the last frame loops to not play it again)
Then in the same state you could use ACS_(Named)Execute to execute a script which does things.
There's a handy reference on the wiki here that might help.
I haven't used models before, but it's probably possible to play an animation in the Active state that ends with "Wait" keyword. (So the last frame loops to not play it again)
Then in the same state you could use ACS_(Named)Execute to execute a script which does things.
There's a handy reference on the wiki here that might help.
Re: Using Models as Switch
The other thing that might be useful is to make the switch visual (and possibly audio too) only. It would depend on what you needed, of course, but if the switch was a just switchable decoration, the activation could be on a line (as per normal) and the line could run a script that, as well as doing whatever the script needs to do, it would activate/deactivate the switch actor to get it to change appearance.
Switchable decorations work just fine with models. I don't think I've ever used "wait" with them (not saying it's bad). A sprite duration of -1 followed by Stop (for both active and inactive states) works in the actors I've made.
Switchable decorations work just fine with models. I don't think I've ever used "wait" with them (not saying it's bad). A sprite duration of -1 followed by Stop (for both active and inactive states) works in the actors I've made.
Re: Using Models as Switch
Thanks Everyone, I will try your suggestions.
Re: Using Models as Switch
I just threw this together. It's a bit rough and ready, but it does the job.
Re: Using Models as Switch
Thanks Enjay , I really appreciate itEnjay wrote:I just threw this together. It's a bit rough and ready, but it does the job.
It's working great!
- ramon.dexter
- Posts: 1529
- Joined: Tue Oct 20, 2015 12:50 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Kozolupy, Bohemia
Re: Using Models as Switch
I can remember that I used voxel based switches back in the days. Also, I can recall that I've downloaded it from somewhere around here ( I mean this forum), but that's all I can remember.
edit: Yup, Doom voxel project has working voxel switches. So you can look how voxel doom did it. If my memory is correct, it is made purely in decorate (which fully supports it).
https://doomwiki.org/wiki/Doom_voxel_project
edit: Yup, Doom voxel project has working voxel switches. So you can look how voxel doom did it. If my memory is correct, it is made purely in decorate (which fully supports it).
https://doomwiki.org/wiki/Doom_voxel_project
Re: Using Models as Switch
I think it looks as if they are doing something very similar to my initial suggestion: a switchable decoration that activates its special when used.
Re: Using Models as Switch
@Enjay, Its working like a charm , Thanks
What other states can i use with Switch actor? Just curious...
What other states can i use with Switch actor? Just curious...
- Attachments
-
- Zrift-Switch03-Testmap.pk3
- Here is the file:
- (74.75 KiB) Downloaded 35 times
Re: Using Models as Switch
Nice.
I'm sure you are aware but the off-to-on animation shows the lever moving smoothly through its arc. The on-to-off animation just snaps back to the off position. You can, of course, set it up to have a smooth animation in both directions.
I'm sure you are aware but the off-to-on animation shows the lever moving smoothly through its arc. The on-to-off animation just snaps back to the off position. You can, of course, set it up to have a smooth animation in both directions.
Re: Using Models as Switch
Yes i was trying to do that but did not figure how to do it properly.Enjay wrote:Nice.
I'm sure you are aware but the off-to-on animation shows the lever moving smoothly through its arc. The on-to-off animation just snaps back to the off position. You can, of course, set it up to have a smooth animation in both directions.
Re: Using Models as Switch
Basically in exactly the same way as you did for the other direction. To make it look neat you just need to make sure that you skip the animation when the switch first spawns.
[edit]
Actually, this would be better with your example.
DECORATE
No need to change the MODELDEF at all.
Forget the bit that follows this edit.
[/edit]
e.g. you could do it this way:
DECORATE
MODELDEF
It would probably need a bit of tweaking but replacing your DECORATE and MODELDEF with that has the switch working in both directions.
[edit]
Actually, this would be better with your example.
DECORATE
Code: Select all
ACTOR ModelSwitch1 : SwitchableDecoration
{
Radius 16
Height 16
+NOGRAVITY
+DONTSPLASH
States
{
Spawn:
goto Inactive +8
Inactive:
POSS IHGFEDCB 1
POSS A -1
Stop
Active:
POSS BCDEFGHI 1
POSS Z -1
Stop
}
}
Forget the bit that follows this edit.
[/edit]
e.g. you could do it this way:
DECORATE
Code: Select all
ACTOR ModelSwitch1 : SwitchableDecoration
{
Radius 16
Height 16
+NOGRAVITY
+DONTSPLASH
States
{
Spawn:
goto Inactive +8
Inactive:
POSS JKLMNOPQ 1
POSS A -1
Stop
Active:
POSS BCDEFGHI 1
POSS Z -1
Stop
}
}
Code: Select all
Model ModelSwitch1
{
Path "Models"
Model 0 "SWITCH03.md3"
Skin 0 "Switch03_redlight.png"
Scale 0.55 0.55 0.4
AngleOffset 90
PitchOffset 0
RollOffset 90
FrameIndex POSS A 0 0
}
Model ModelSwitch1
{
Path "Models"
Model 0 "SWITCH03.md3"
Skin 0 "Switch03_nolight.png"
Scale 0.55 0.55 0.4
AngleOffset 90
PitchOffset 0
RollOffset 90
FrameIndex POSS B 0 1
FrameIndex POSS C 0 2
FrameIndex POSS D 0 3
FrameIndex POSS E 0 4
FrameIndex POSS F 0 5
FrameIndex POSS G 0 6
FrameIndex POSS H 0 7
FrameIndex POSS I 0 8
}
Model ModelSwitch1
{
Path "Models"
Model 0 "SWITCH03.md3"
Skin 0 "Switch03_light.png"
Scale 0.55 0.55 0.4
AngleOffset 90
PitchOffset 0
RollOffset 90
FrameIndex POSS Z 0 9
FrameIndex POSS J 0 8
FrameIndex POSS K 0 7
FrameIndex POSS L 0 6
FrameIndex POSS M 0 5
FrameIndex POSS N 0 4
FrameIndex POSS O 0 3
FrameIndex POSS P 0 2
FrameIndex POSS Q 0 1
}
Re: Using Models as Switch
Got it, Thanks !
Working like a charm
Working like a charm
- Attachments
-
- Zrift-Switch03-Testmap-Rev1.pk3
- (75.07 KiB) Downloaded 30 times
Re: Using Models as Switch
Hi,
the switch is cool, but...
I fixed some more issues to make it easier to work with:
-fixed x,y,z offsets and removed lines from modeldef
-scaled to 50%
-added Icon
-changed frames from POSS to SWT3
No more fiddling around in Doombuilder, just stick the switch to the wall and done. Bonus: Nice Icon
Tnx for starting this threat, it always helps a lot!
Info: Testmapfixed and pulled out of pk3
the switch is cool, but...
I fixed some more issues to make it easier to work with:
-fixed x,y,z offsets and removed lines from modeldef
-scaled to 50%
-added Icon
-changed frames from POSS to SWT3
No more fiddling around in Doombuilder, just stick the switch to the wall and done. Bonus: Nice Icon
Tnx for starting this threat, it always helps a lot!
Info: Testmapfixed and pulled out of pk3
- Attachments
-
- MAP01.wad
- (6.22 KiB) Downloaded 20 times
-
- SWITCH03Rev2.pk3
- (145.61 KiB) Downloaded 24 times