Vehicle with gun
|
Disco Duck
Registered User
Join date: 22 Dec 2004
Posts: 49
|
02-01-2005 18:25
I am trying to make a sort of missile launching vehicle, and I cannot seem to get the missile to rez in the same place in relation to the vehicle. To be a bit more specific, the vehicle has a button on it, when you touch the button, a missile should rez on top of the vehicle. Right now, I can get the missile to spawn as long as it is facing in one direction, but if i rotate the vehicle, the missile rezzes facing the same direction as it was before. I tried using llGetRot() as well as llGetRootRotation() but it didn't seem to make a difference. Any body have any clue? (Or an example of a general weapon script on a vehicle?)
|
Fafnir Fauna
Downy Cat
Join date: 23 Jun 2004
Posts: 34
|
02-02-2005 09:17
It worked alright for me.. I used: default { touch_start(integer total_number) { llRezObject("missile", llGetPos(), ZERO_VECTOR, llGetRot(), 0); } }
Now making the object 'shoot' in the right direction is another story. Simply pushing the object on the same rotation of the vehicle is not enough. It will just shoot the missile in the same direction every time no matter which way the vehicle is facing. What you need to do in this case is to get a forward vector with llRot2Fwd(). Something like this: rotation rot; vector fwd; vector pos;
default { touch_start(integer total_number) { rot = llGetRot(); pos = llGetPos(); fwd = llRot2Fwd(rot); pos += fwd; fwd *= 50.0; // The ammount of force to push the object with
llRezObject("missile", pos, fwd, rot, 0); } }
Of course you'll have to modify this code, because this will rez the missile on your button rather than from the launcher or whatever you use to house the missile. I'd use a llMessageLinked() on the button, and a link_message() in place of touch_start() with the above code in it on the prim you want the missile launched from.
|
Ferran Brodsky
Better living through rum
Join date: 3 Feb 2004
Posts: 821
|
02-02-2005 09:20
IronChef has a Roach Coach that shoots tacos (no, it doesnt shoot the upskirt guy, although that would be funny too)
|
Disco Duck
Registered User
Join date: 22 Dec 2004
Posts: 49
|
02-02-2005 14:31
Awesome, I'll try that out =D
|
gene Poole
"Foolish humans!"
Join date: 16 Jun 2004
Posts: 324
|
03-18-2005 23:32
On a somewhat related note, when you rez a bullet, is its initial orientation at all related to its orientation when rezzed from your inventory onto the ground? I dissassembled a "Summer Camp Bow" and discovered that the "arrow" object it contains faces down when dragged out of contents onto the ground. The arrow fires facing "forward" (as expected). But when I placed my own (test) projectile (which also faces tip-down on its own) into the bow, it fired tip-up. Beuh?! 
|
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
|
03-19-2005 01:46
From: gene Poole On a somewhat related note, when you rez a bullet, is its initial orientation at all related to its orientation when rezzed from your inventory onto the ground? I dissassembled a "Summer Camp Bow" and discovered that the "arrow" object it contains faces down when dragged out of contents onto the ground. The arrow fires facing "forward" (as expected). But when I placed my own (test) projectile (which also faces tip-down on its own) into the bow, it fired tip-up. Beuh?!  Actually, no, it doesn't take that into consideration at all. What does happen is the script will rez an object with a rotation it's been supplied by the scripter. Now, the reason that yours is coming out at an angle is because the root prim of your object is 180 degrees inverted compared to the root prim of the original. You're thinking in terms of a finished arrow, where it's logical which end is pointy and how it's supposed to work. You need to also think of it in terms of a collection of individual prims. SL doesn't know which end is up. It only knows the rotation, position and scale of individual prims. For example, try rezzing both the original arrow and yours on the ground. Check the rotation of the root prims. See? (Local Axis is very useful here too.)
|
Eggy Lippmann
Wiktator
Join date: 1 May 2003
Posts: 7,939
|
03-19-2005 02:06
I'd say, forget about its initial rotation and use ll[Rot]LookAt to point at the missile's target. I <3 those functions 
|
gene Poole
"Foolish humans!"
Join date: 16 Jun 2004
Posts: 324
|
03-19-2005 09:35
Thanks, Catherine, I played around with it and figured out what you meant. The way the various settings interact, I couldn't get what I wanted exactly, so I just made an extra invisible (zero-alpha) prim to use as my root, and oriented it correctly.
Eggy, I wouldn't mind using that, but I don't want to deal with the damping crap; I want the object to start life "correctly" oriented. Still, your input is appreciated.
|