Jump to content

Using the Jumppad script tutorial, I tried to add sound...


MisterGravity
 Share

Recommended Posts

Please note, I'm still very new at the Lua scripting. I'm trying!

 

Using nate066's Jump-Pad tutorial script located here, I tried to use some skills I learned from Rick in his Teleportation tutorial located here.

 

Specifically, once Rick implemented the teleporter pads, he created a couple of Pivots in the scene to hold the Noise.lua scripts. I learned that a function Script:Whatever could be called in the Flowgraph Editor to call outputs, like this:

 

self.component:CallOutputs("TriggerEnter")

 

Which would let him use it in the Flowgraph Editor, like this:

 

tumblr_mzdjp3VfXA1qk5t55o1_400.jpg

 

So what I did was, I tried to use that knowledge to edit the Jumppad script to also be able to call a similar Pivot when the collision occurred. The problem (and it's not really a problem, it just wasn't conducive to what I wanted to do,) was that the JumpPad's action was all happening in the function Script:Collision area of the code. My assumption was that I could remove what made it work and put it in it's own function instead, and then use a "CallOutput" to be able to use it in the Flowgraph Editor too.

 

This was what I was hoping would work, but does not.

 

tumblr_mzdjwtk8Rt1qk5t55o1_400.jpg

 

And this is the code as it was when I altered it:

 

Script.JumpForce = nil --vec3
Script.SelectiveCollision = false --bool "Selective Collision"
Script.ColObj = nil --Entity "Collision Object"

function Script:Start()
 self.source = Source:Create()
end

function Script:Collision(entity, position, normal, speed)
 if (self.SelectiveCollision == true and entity == self.ColObj) then
	 self.source:Jump()
 elseif (self.SelectiveCollision == false) then
	 entity:AddForce(self.JumpForce)
 end
end

function Script:Jump()
 self.component:CallOutputs("Jump")
 self.ColObj:AddForce(self.JumpForce)
end

 

Does anyone have any thoughts on this? And nate, this was not intended to sidestep you or go over your head. You and I had talked together on trying to encorporate sound directly into it, but I thought I'd take it public since I'm now trying to add in pieces of Rick's project as well.

 

Thanks everyone!

I'm sure I'll have a million questions in my quest to master the Leadwerks Engine. Thank you for your patience.

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...