Sonii Huntsman Posted July 26 Posted July 26 I was wondering if someone could help me. I will start off slowly. I looked into an older post about scripts for balls and not sure which lines go where on a script that was located there. Any help would be fabulous. vector gGrabVec;default{ state_entry() { llSetStatus(STATUS_PHYSICS,FALSE); // Start non-physical } touch(integer num) { gGrabVec = llDetectedGrab(0); // Get the current offset vector float Mag = llVecMag(gGrabVec); // and its magnitude llSetText("Power = " + (string)((integer)(10*Mag)),<0,1,0>,1.0); } touch_end(integer num) { llSetStatus(STATUS_PHYSICS,TRUE); // Make the object physical llSetTimerEvent(2.0); // Turn the safety on llApplyImpulse(-5*gGrabVec, FALSE); // Scale the offset vector and apply it * -1 } timer() { llSetTimerEvent(0.0); llOwnerSay((string)llGetPos()); // Where am I? llSetStatus(STATUS_PHYSICS,FALSE); // Stop rolling llSetText("",<0,1,0>,1.0); }}
Rolig Loon Posted July 26 Posted July 26 That script turns the ball physical when you click and then release it. If that's all that you do, the ball will just sit there. If you click, hold, and drag the ball, though, the ball will keep moving for two seconds. The speed and direction of the ball will depend on how quickly and in what direction you drag it between clicking and unclicking. It's a pretty simple script. You can change the amount of force applied by messing with the "-5" value in the llApplyImpulse function and you determine when the ball stops by changing the value in the llSetTimerEvent function. Consult the LSL wiki to see how those functions work, and then just start playing. The script looks remarkably similar to something I remember writing ages ago when I was playing with ways to make a golf game. It might even be mine. Anyway, golf balls are like other physical projectiles (bullets, arrows, meteors, ...), so you can widen your search and learn other ways of describing the task by looking at other projectile scripts.
PheebyKatz Posted July 27 Posted July 27 I once made a field hockey set that worked okay, but I found it almost impossible to get a scripted ball to work as well as an unscripted, physical one with the physics set properly. I ended up doing as Rolig mentions above, and simply using the ball as a projectile. If you get this to do as you wish, please come back and show us, I would love to see your solution!
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