Jump to content

Spawning objects with a trigger


lxFirebal69xl
 Share

Recommended Posts

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? :P

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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. wink.png (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? :P

Sorry I'm really bad at LUA

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

  • Upvote 1
Link to comment
Share on other sites

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 :D

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...