Jump to content

SetElasticity and SetSoftness functions? (Lua)


whiterabbit
 Share

Recommended Posts

I have a model of a sphere with a collision mesh imported into Leadwerks and I wanted to control how 'bouncy' it was. Did a google search and came across the functions SetElasticity and SetSoftness (seems like they were called SetBodyElasticity and SetBodySoftness in older versions).

 

The current docs don't mention these functions, or at least not on Entity, and when I try to call them they obviously don't exist. Does anyone know if they've been renamed, not available to Lua, removed for some reason?

 

Just a few things I found:

http://www.leadwerks.com/werkspace/topic/2546-balls/ (This has a Lua script that calls SetElasticity which makes me think it did exist at some point)

http://www.leadwerks.com/werkspace/page/Documentation/le2/_/command-reference/bodies/setbodyelasticity-r58 (Old docs)

http://www.leadwerks.com/werkspace/topic/4683-problem-with-collision-callback/ (C++ but calls SetElasticity)

Link to comment
Share on other sites

It seems that those are older functions from LE 2. At the moment I do not believe such functions exist (at least for lua). I had a similar issue so I made a little script for my ball to make it bounce. It looked like this -

 

function Script:Collision(entity, position, normal, speed)

self.entity:AddForce(0,.25*speed,0) -- Add Global force to make the ball bounce upwards.

self.entity:AddForce(0,.25*speed,0,false) -- Add Local force to make the ball have a random bounce

end

Check out my game Rogue Snowboarding- 

https://haydenmango.itch.io/roguesnowboarding

Link to comment
Share on other sites

It seems that those are older functions from LE 2. At the moment I do not believe such functions exist (at least for lua). I had a similar issue so I made a little script for my ball to make it bounce. It looked like this -

 

function Script:Collision(entity, position, normal, speed)

self.entity:AddForce(0,.25*speed,0) -- Add Global force to make the ball bounce upwards.

self.entity:AddForce(0,.25*speed,0,false) -- Add Local force to make the ball have a random bounce

end

 

Thanks, I thought that might be the case. I just didn't want to have to do it myself.

Link to comment
Share on other sites

Yep, I'm already going to be doing those things in different situations so it's not really a simple option. Gravity is disabled on the world and the ball applies a force to itself to simulate gravity so I can change the direction of gravity (not sure if you can change the gravity direction for the entire world?). I'll try and work around it for now.

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