Jump to content

Tealthantos

Resident
  • Posts

    34
  • Joined

  • Last visited

Everything posted by Tealthantos

  1. Since my first attempt at creating a turret (http://community.secondlife.com/t5/LSL-Scripting/Lost-in-the-world-of-rotations/td-p/1666849) I've come across another turret script that I've been attempting to modify for my tank, however I've been having problems getting it to follow both the Z and Y axis at the same time, when I turn the turret and increase the elevation - it will return to zero rotation then will elevate up along the y axis before returning to zero rotation then back to its location along the Z axis. Here is the script - rotation old_rot; key pilot; vector calculate_rot; float scan_delay = .01; float max_roty=8; float max_rotz=8; rotateToz(float angle) { rotation new_rotz = llEuler2Rot(<0,0,angle>); float aim_change=llFabs(llAngleBetween(old_rot,new_rotz)); if(aim_change > max_rotz) { calculate_rot = llRot2Euler(llEuler2Rot(<0,0,angle>)/old_rot); if(calculate_rot.z > max_rotz) calculate_rot.z=max_rotz; else calculate_rot.z=-max_rotz; old_rot = llEuler2Rot(calculate_rot)*old_rot; } else{ old_rot = new_rotz;} llSetLocalRot(new_rotz); } rotateToy(float angle) { rotation new_roty = llEuler2Rot(<0,angle,0>); float aim_change=llFabs(llAngleBetween(old_rot,new_roty)); if(aim_change > max_roty) { calculate_rot = llRot2Euler(llEuler2Rot(<0,angle,0>)/old_rot); if(calculate_rot.y > max_roty) calculate_rot.y=max_roty; else calculate_rot.y=-max_roty; old_rot = llEuler2Rot(calculate_rot)*old_rot; } else{ old_rot = new_roty; } llSetLocalRot(new_roty); } default { on_rez(integer t) { llResetScript(); } link_message(integer sender, integer channel, string message, key id) { if(message=="seated") { pilot = id; if(channel) { llSetTimerEvent(scan_delay); }else { llSetTimerEvent(0); } } } timer() { llSetTimerEvent(0); integer info = llGetAgentInfo(pilot); if((info & AGENT_MOUSELOOK) && (info & AGENT_SITTING)) { llSensor("", pilot, AGENT, 10.0, TWO_PI); }else { llSetTimerEvent(scan_delay); } } sensor(integer num_detected) { llSetTimerEvent(0); { vector compensated = llRot2Euler(llGetRootRotation() / llDetectedRot(0)); rotateToy(compensated.y * -1); rotateToz(compensated.z * -1); llSetTimerEvent(scan_delay); } } } Now I suspect this part here is the problem { vector compensated = llRot2Euler(llGetRootRotation() / llDetectedRot(0)); rotateToy(compensated.y * -1); rotateToz(compensated.z * -1); llSetTimerEvent(scan_delay); } But however I am a bit unsure as my abilities with second life script leaves a -lot- to be desired. Any help would be appreciated.
  2. Innula Zenovka wrote: I don't quite understand from the fragment of code what's supposed to happen -- in particular, it's not clear who is in mouselook or whose (or what's) rotation is being detected. Be that as it may, this tutorial by Chalice Yao, over at SLU, help you do what you're trying to: http://www.sluniverse.com/php/vb/script-library/40698-kept-simple-rotate-object-towards.html Thanks, however that ended up not being the problem. Turns out the prim was taking rotations from 2 points - camera and where the tank's camera was set. Now I just need to figure out how to get it to ignore the tank perspective camera =(
  3. Hey guys. Been trying to put together a turret script for a vice tank I've been building, I've got most of it sorted but however I've run into a impass when It comes to the prim acting as the spawn point for the cannon bullet, when the tank turns and I look in a direction I want the prim to turn to face the direction I'm looking in - however when I turn the tank and look, the whole prim flips and rotates based in the direction I've turned not the direction I've been looking in. if(buf & AGENT_MOUSELOOK){llGetLocalRot(); llSetLocalRot((root = ZERO_ROTATION / root) * llDetectedRot(0)); Is the script line, but I can't figure out why its flipping based on direction of facing of the root prim - feels like I'm missing something simple, but I can't for the life of me pick it.
  4. Tried what you said and it worked fine - thanks for your help!
  5. So I've been building a Su-25, but I've been having problems with the flaps. As we all know when you rotate a object it doesn't move leaving overlap or open joints so I added a set position command to change the relative pos as it rotates. integer flaps=TRUE; Flaps() {if (flaps==TRUE) { rotation rot = llGetLocalRot(); rot.z = -0.644333; rot.s = 0.652586; rot.x = 0.297774; rot.y = -0.265136; llSetLocalRot(rot); llSetPos(llGetPos() + <0,0,-0.9>); flaps = FALSE;} else {if (flaps==FALSE) { rotation rot = llGetLocalRot(); rot.z = -0.707107; rot.s = 0.707107; rot.x = 0.000000; rot.y = 0.000000; llSetLocalRot(rot); llSetPos(llGetPos() + <0,0,0.9>); flaps = TRUE;} } } default { state_entry() { llListen(0,"", NULL_KEY, ""); } listen(integer channel, string name, key id, string message) { if (message == "Flaps") {Flaps();} }} But for some reason it won't move and will just rotate on the spot. Help would be much appreciated
  6. Today I was cruising the blake sea in my new fighter in the "free combat" area when I spotted a boat cruising the surface - Thinking I would get a chance to test out the combat I dove in....... A minute later I found my plane hijacked via edit, told I was in violation of the CoC and told if I involved myself in combat I would never fly again and would be banned from the Blake sea. Weird I thought to myself and ask the person to explain and was told to hunt down the rules in game and see for myself, when I did finally find a airstrip with said rules I found out they were the individual rules of one sim, which basically consisted of "no combat unless we say so and by our rules of engagement" My question is - should one organization have such power over what should be a free area? and if so, should not these rules be distributed as much as possible so others don't make the mistake I did? Also if anyone knows of a free aircombat area on the Main Land I would be grateful to know of it........
  7. Thanks for the responses guys, found my solution with the multi-move script! But the solutions suggested here won't go to waste, this thing is a pain to pack! Party on board when she's done!
  8. Just starting out with building with second life, with my second creation (a airship) going well, however I've had problems attaching things like doors to the thing, and while watching my airship opening and closing was rather funny I was wondering if there was a way to bundle linked objects without scripts interfering with other linked objects?
×
×
  • Create New...