Rolig Loon Posted May 26, 2011 Share Posted May 26, 2011 I'm just playing, and I can't seem to figure out the right geometry to get a silly toy to work right. It's basically a trampoline, for which I can easily writedefault { collision(integer total_number) { vector AvPos = llDetectedPos(0); vector MyPos = llDetectedTouchPos(0); vector Go = llVecNorm(<0.0,0.0,AvPos.z - MyPos.z>); llPushObject(llDetectedKey(0), Go * 30,ZERO_VECTOR,TRUE); } } That works fine, except that the push is always directed from the center of the trampoline prim. That means I get a better bounce at the middle than at the edges -- OK for a tiny trampoline, but not for a big one. I thought maybe I could scale the vector Go by my angular distance from the center of the trampoline, something like this...vector Go = llVecNorm(<0.0,0.0,AvPos.z - MyPos.z>)*llSin(llRot2Angle(llRotBetween(llVecNorm(AvPos),<0.0,0.0,1.0>))); but it makes very little difference. I'm clearly not visualizing the geometry correctly. Any ideas? Link to comment Share on other sites More sharing options...
Kayaker Magic Posted May 26, 2011 Share Posted May 26, 2011 I think you wanted llRotBetween(llVecNorm(AvPos-MyPos),<0,0,1>) AvPos is in region co-ordinates, and you want the little vector from the center. HOWEVER, doesn't llPushObject have a wierd-strange fall-off with distance from the center of the prim and the mass of the pushee, or the pusher, or which ever one doesn't make sence? I recall trying to compensate for this once and just running out of "energy" instead. Link to comment Share on other sites More sharing options...
Qie Niangao Posted May 26, 2011 Share Posted May 26, 2011 Gee, I don't think it's that complicated, if the object is always supposed to push upwards with the same result regardless of where on the surface the collision is made. The only thing is that the force falls off as a function of the distance cubed, so... something like this, maybe: default{ collision(integer total_number) { key av = llDetectedKey(0); vector AvPos = llDetectedPos(0); vector myPos = llGetPos(); vector up = <0.0, 0.0, 1.0>; float distance = llVecMag(AvPos - myPos); llPushObject(av, up*30.0*llPow(distance, 3.0), ZERO_VECTOR, TRUE); }} I think you may also want some kind of initial de-bouncing because I think you're likely to get two collision events right at the beginning. (Or maybe I'm not understanding the project.) Link to comment Share on other sites More sharing options...
Rolig Loon Posted May 26, 2011 Author Share Posted May 26, 2011 You're right. I spotted that after I posted too. :smileytongue: It still doesn't help, though. The real problem is exactly as you said: the intensity of llPushObject does fall off from the center of the prim. That's the effect that I'm trying to counterbalance, without any luck. I thought I could do it by applying some sort of gain to my Go vector that increases with distance from the center. Either I just haven't hit on a decent function (a very likely possibility) or it can't be done (a disappointing one). This isn't a major issue, BTW. I only started playing with it because I got curious about how llPushObject works. I still don't know. Link to comment Share on other sites More sharing options...
Rolig Loon Posted May 26, 2011 Author Share Posted May 26, 2011 Hehehe... It shouldn't be too complicated, you're right. As I just replied to Kayaker, I think I just haven't hit on the right function to describe the falloff yet. I should have thought of your idea, though .... a simple inverse cube law. Now I can't get in world to try it out until this evening. :=p Link to comment Share on other sites More sharing options...
Rolig Loon Posted May 26, 2011 Author Share Posted May 26, 2011 Yup. Works like a dream. Thanks, Qie. There's one fewer mysteries in my world now. Link to comment Share on other sites More sharing options...
Randall Ahren Posted May 27, 2011 Share Posted May 27, 2011 For uniform bouncing, you need a more well endowed avatar. Momentum is proportional to mass and velocity, so increase the mass. That should make the uniform appear to bounce more. Link to comment Share on other sites More sharing options...
Void Singer Posted May 27, 2011 Share Posted May 27, 2011 ::here's me hoping that was dry humor:: Link to comment Share on other sites More sharing options...
Rolig Loon Posted May 27, 2011 Author Share Posted May 27, 2011 I was ignoring it gracefully. :smileyindifferent: Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now