lxFirebal69xl Posted January 31, 2015 Share Posted January 31, 2015 As the title says, how would I do this? For example, a player using a switch and a key appearing on top of a table, and the key wasn't there before. Quote Link to comment Share on other sites More sharing options...
Genebris Posted January 31, 2015 Share Posted January 31, 2015 Easiest way: Place your key on a table mark it as hidden in it's properties (Appearance tab). Add this script to your lever: Script.key=nil --entity "Key" function Script:Use() self.key:Show() end And drag the key from scene tree window to a script variable field called "Key". Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted January 31, 2015 Author Share Posted January 31, 2015 Easiest way: Place your key on a table mark it as hidden in it's properties (Appearance tab). Add this script to your lever: Script.key=nil --entity "Key" function Script:Use() self.key:Show() end And drag the key from scene tree window to a script variable field called "Key". Works perfectly, thank you! Now, how do I make an object spawn with a collision trigger? Quote Link to comment Share on other sites More sharing options...
beo6 Posted January 31, 2015 Share Posted January 31, 2015 Look into your Scripts/Objects/Triggers/ folder for "CollisionTrigger.lua". I think that should help you. Just change the key script to something like function Script:Show()--in self.entity:Show() end and connect them in the flowgraph //edit. fixed that you don't need to assign the key in script when you already assign the script to the key. (its late) Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted February 1, 2015 Author Share Posted February 1, 2015 Look into your Scripts/Objects/Triggers/ folder for "CollisionTrigger.lua". I think that should help you. Just change the key script to something like function Script:Show()--in self.entity:Show() end and connect them in the flowgraph //edit. fixed that you don't need to assign the key in script when you already assign the script to the key. (its late) Thanks for that one beo6! But now I got another issue, I'm trying to make a barrel appear in the air so it falls down, makes a noise and scare the player. Everything works fine except the barrel doesn't appear at all, every other object without physics or mass appear, how can I do this? Sorry I'm really bad at LUA Quote Link to comment Share on other sites More sharing options...
beo6 Posted February 1, 2015 Share Posted February 1, 2015 no problem lxFirebal69xl. I hope you get it soon. It is really easy and you can see a lot of useful scripting parts in the already existing scripts. For example for what you want i just put together what i posted and the existing script under "Scripts/Objects/Physics/ImpactNoise.lua". additionally i just set the Mass to 0 to disable the physic on start and reset it when it is shown. ShowHideImpact.lua Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted February 1, 2015 Author Share Posted February 1, 2015 no problem lxFirebal69xl. I hope you get it soon. It is really easy and you can see a lot of useful scripting parts in the already existing scripts. For example for what you want i just put together what i posted and the existing script under "Scripts/Objects/Physics/ImpactNoise.lua". additionally i just set the Mass to 0 to disable the physic on start and reset it when it is shown. ShowHideImpact.lua I still have the same problem, whenever I put it to activate physics after the object shows up, it doesn't show up at all, otherwise it shows up but doesn't do anything, it just stays there. Quote Link to comment Share on other sites More sharing options...
beo6 Posted February 1, 2015 Share Posted February 1, 2015 You need to have the option enable physic disabled in the script tab. I only wanted to keep it compatible with the original impact script so this defines the physic on start. I tested the script and it works for me. Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted February 1, 2015 Author Share Posted February 1, 2015 You need to have the option enable physic disabled in the script tab. I only wanted to keep it compatible with the original impact script so this defines the physic on start. I tested the script and it works for me. Same thing keeps happening, I push the button, and the object (in this case a barrel) either stays in the air (because I put it there) or doesn't show up at all. Physics disabled=Show up, but doesn't fall down Physics enabled= Doens't show up at all Sorry, I'm really bad at this Quote Link to comment Share on other sites More sharing options...
beo6 Posted February 1, 2015 Share Posted February 1, 2015 Physics disabled is correct. But do you have also set the Physics in the Physics tab? Set it to Rigid Body set a collision shape give it a mass higher than 0 set type to Prop and you should be good to go. Sorry the checkbox should really be named "Physics enabled at start" or something like that. 1 Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted February 1, 2015 Author Share Posted February 1, 2015 Physics disabled is correct. But do you have also set the Physics in the Physics tab? Set it to Rigid Body set a collision shape give it a mass higher than 0 set type to Prop and you should be good to go. Sorry the checkbox should really be named "Physics enabled at start" or something like that. I got it working, thank you so much Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.