RayRobert Posted December 17, 2013 Share Posted December 17, 2013 Hello all, I am fairly new to dcriptin and am modifying a vehicle script. The script doesnt make the wheels spin when moving forward or backward. Can anyone assist me in doing this? I know I need to use link message to communicate between prims but am not dure exactly how. Link to comment Share on other sites More sharing options...
steph Arnott Posted December 17, 2013 Share Posted December 17, 2013 Some reading. http://wiki.secondlife.com/wiki/LlSetPrimitiveParams#llSetLinkPrimitiveParamsFast http://wiki.secondlife.com/wiki/Link_Messages BTW, A texture rotating maybe easier, but things have moved on since I did this stuff. Link to comment Share on other sites More sharing options...
Freya Mokusei Posted December 17, 2013 Share Posted December 17, 2013 There'll be a separate script for you to put in each wheel. When the vehicle is linked, this link message will send to those child scripts. Note that this is not the best way to achieve that functionality, you're probably using old (and obselete) scripts. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted December 17, 2013 Share Posted December 17, 2013 Most older vehicle scripts use link messages to control script in the wheel prims, to turn llTargetOmega on and off. Now you don't need to do that, since you can use llSetLinkPrimitiveParamsFast to control PRIM_OMEGA. Note that you can control all four wheels in one call, by saying llSetLinkPrimitiveParamsFast(LINK_SET,[PRIM_LINK_TARGET,wheel_1, some params,PRIM_LINK_TARGET,wheel_2, some params...]); Link to comment Share on other sites More sharing options...
Madelaine McMasters Posted December 17, 2013 Share Posted December 17, 2013 Innula Zenovka wrote: Most older vehicle scripts use link messages to control script in the wheel prims, to turn llTargetOmega on and off. Now you don't need to do that, since you can use llSetLinkPrimitiveParamsFast to control PRIM_OMEGA. Note that you can control all four wheels in one call, by saying llSetLinkPrimitiveParamsFast(LINK_SET,[PRIM_LINK_TARGET,wheel_1, some params,PRIM_LINK_TARGET,wheel_2, some params...]); And I think (correct me if I'm wrong, Innula) that if your wheels are simple textured cylinders, Steph's suggestion to rotate the texture is best, as llTargetOmega's rotation vector must be changed if the vehicle's front wheels are steerable. Texture rotation doesn't care about prim orientation. llSetTextureAnim(ANIM_ON | SMOOTH | ROTATE | LOOP, 0,1,1,0, rotation_rate, 1); for example. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted December 18, 2013 Share Posted December 18, 2013 Yes, you need to keep calling it to adjust the rotation according to the each wheel prim's local rotation, but I don't see that as a problem, since you're going to need to keep calling it anyway, when the car's speed changes, and it's no big deal to call it again in the control events when you change the car's direction. Something like this integer i= -llGetListLength(wheels); list params; float speed = llVecMag((llGetVel()*llGetRot())); do { integer n = llList2Integer(wheels,i); list l =llGetLinkPrimitiveParams(n,[PRIM_ROT_LOCAL,PRIM_SIZE]); rotation r = llList2Rot(l,0); vector size = llList2Vector(l,1); float circumference = size.x*PI; params += [PRIM_LINK_TARGET]+[n]+[PRIM_OMEGA]+[<0.0,0.0,(speed/circumference)>*r,TWO_PI,0.1]; } while(++i); llSetLinkPrimitiveParamsFast(LINK_SET,params); Link to comment Share on other sites More sharing options...
LepreKhaun Posted December 18, 2013 Share Posted December 18, 2013 Innula Zenovka wrote: Yes, you need to keep calling it to adjust the rotation according to the each wheel prim's local rotation, but I don't see that as a problem, since you're going to need to keep calling it anyway, when the car's speed changes, and it's no big deal to call it again in the control events when you change the car's direction. Something like this integer -i=llGetListLength(wheels); list params; float speed = llVecMag((llGetVel()*llGetRot())); do { integer n = llList2Integer(wheels,i); list l =llGetLinkPrimitiveParams(n,[PRIM_ROT_LOCAL,PRIM_SIZE]); rotation r = llList2Rot(l,0); vector size = llList2Vector(l,1); float circumference = size.x*PI; params += [PRIM_LINK_TARGET]+[n]+[PRIM_OMEGA]+<0.0,0.0,(speed/circumference)>*r,TWO_PI,0.1]); } while(++i); llSetLinkPrimitiveParamsFast(LINK_SET,params); Careful, that code won't compile. // Syntax error for not following lhs/rhs rules.integer -i=llGetListLength(wheels); // Syntax error from poorly written list.params += [PRIM_LINK_TARGET]+[n]+[PRIM_OMEGA]+<0.0,0.0,(speed/circumference)>*r,TWO_PI,0.1]); Link to comment Share on other sites More sharing options...
Innula Zenovka Posted December 18, 2013 Share Posted December 18, 2013 Oops. Now fixed. Sorry about that. Link to comment Share on other sites More sharing options...
Freya Mokusei Posted December 18, 2013 Share Posted December 18, 2013 Madelaine McMasters wrote: llSetTextureAnim(ANIM_ON | SMOOTH | ROTATE | LOOP, 0,1,1,0, rotation_rate, 1); This is (almost) what I would recommend using. More specifically:- llSetLinkTextureAnim Which removes the need for barely used child scripts. If the OP goes the OMEGA route, disregard this post! Link to comment Share on other sites More sharing options...
steph Arnott Posted December 18, 2013 Share Posted December 18, 2013 All very clever, but I be amazed if anyone could tell whether the texture rotating matches the velocity. Just seems overkill and more math work than needed. Link to comment Share on other sites More sharing options...
LepreKhaun Posted December 18, 2013 Share Posted December 18, 2013 np, as Donald E. Knuth once said, "Beware of bugs in the above code; I have only proved it correct, not tried it." Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now