Jump to content

making wheels rotate for a vehicle


RayRobert
 Share

Recommended Posts

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

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


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

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

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


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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...