Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Define the leg object names
- string leg_top = "leg_top";
- string leg_mid = "leg_mid";
- string leg_bot = "leg_bot";
- // Define the vehicle object name
- string vehicle = "vehicle";
- // Define the position and rotation offsets for each leg object
- vector top_offset = <0.0, 0.0, 0.1>;
- rotation top_rotation = <0.0, 0.0, 0.0, 1.0>;
- vector mid_offset = <0.0, 0.0, -0.2>;
- rotation mid_rotation = <0.0, 0.0, 0.0, 1.0>;
- vector bot_offset = <0.0, 0.0, -0.2>;
- rotation bot_rotation = <0.0, 0.0, 0.0, 1.0>;
- // Define the leg movement variables
- float leg_angle = 0.0;
- float leg_speed = 0.0;
- default
- {
- state_entry()
- {
- // Position and rotate the leg objects relative to the vehicle object
- vector vehicle_pos = llList2Vector(llGetObjectDetails(vehicle, [OBJECT_POS]), 0);
- rotation vehicle_rot = llList2Rot(llGetObjectDetails(vehicle, [OBJECT_ROT]), 0);
- vector top_pos = vehicle_pos + (vehicle_rot * top_offset);
- llSetPos(top_pos);
- llSetRot(vehicle_rot * top_rotation);
- vector mid_pos = top_pos + (vehicle_rot * mid_offset);
- llSetLinkPrimitiveParamsFast(llGetLinkNumber(), [PRIM_POSITION, mid_pos, PRIM_ROTATION, vehicle_rot * mid_rotation]);
- vector bot_pos = mid_pos + (vehicle_rot * bot_offset);
- llSetLinkPrimitiveParamsFast(llGetLinkNumber(), [PRIM_POSITION, bot_pos, PRIM_ROTATION, vehicle_rot * bot_rotation]);
- // Start the leg movement timer
- llSetTimerEvent(0.1);
- }
- timer()
- {
- // Get the vehicle velocity and direction
- vector vehicle_vel = llList2Vector(llGetObjectDetails(vehicle, [OBJECT_VELOCITY]), 0);
- vector vehicle_dir = llRot2Fwd(llList2Rot(llGetObjectDetails(vehicle, [OBJECT_ROT]), 0));
- // Calculate the leg speed based on the vehicle velocity
- leg_speed = llVecMag(vehicle_vel) * llDot(vehicle_dir, llVecNorm(vehicle_vel));
- // Calculate the leg angle based on the leg speed
- leg_angle += leg_speed * 0.01;
- // Calculate the leg position and rotation based on the leg angle
- vector bot_pos = llGetPos() + (llGetRot() * bot_offset);
- rotation bot_rot = llGetRot() * bot_rotation * llEuler2Rot(<0.0, 0.0, leg_angle>);
- // Update the leg position and rotation
- llSetLinkPrimitiveParamsFast(llGetLinkNumber(), [PRIM_POSITION, bot_pos, PRIM_ROTATION, bot_rot]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement