Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Physical objects on a ballistic trajectory

Schmerm Zorger
Registered User
Join date: 21 Jan 2006
Posts: 5
02-11-2006 16:24
Howdy. I'm trying to make a physical object be able to get an initial kick of impulse and then hit a specific location completely under the influence of gravity. I've done this and it's worked perfectly so far, but here's the catch: I need to have the object constantly facing in its direction of movement.

There seemed to be a perfect solution to this: Change the object into a vehicle, set the angular deflection at maximum, and turn off all the other vehicle settings, and use llApplyImpulse just like before to launch the thing. However, there's a problem.

When using the vehicle version, it keeps landing short of its target, as if some kind of friction is acting on it. Now, I've turned off all kinds of vehicle friction (timescale 1000, efficiency 0) and it still does this. Compensating the impulse by a scale factor (like *1.2, *1.3) doesn't really fix the problem, since at certain angles it overshoots. However, targeting was perfect in the non-vehicleized version. I'm pretty sure that I've forced all the stuff like hover and vertical attractor off too (including setting buoyancy to 0).

So what am I missing and how do I get rid of this phantom vehicle friction? Or, should I just give up and use a waypointed llMoveToTarget solution?
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
02-11-2006 16:30
This is just "off the top of my head", there's probably a much better way to go about it:

CODE
default
{
state_entry()
{
llSetTimerEvent(0.0);
}

on_rez(integer n)
{
llSetTimerEvent(0.5);
}

timer()
{
llLookAt(llGetPos() + llGetVel());
}
}
_____________________
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
02-12-2006 03:33
I used llRotLookAt myself, as it makes it easier to move the object to point its forward axis (rather than its up axis) towards direction of movement.

Here's the rotation code from a function that I used to orient a rocket that I blogged recently:
CODE

vector vel = llGetVel();
rotation rot = llGetRot();
llRotLookAt(rot * llRotBetween(<1,0,0> * rot, vel), strength, damping);

strength and damping will have to be set as appropriate for your projectile. I have
CODE

strength = llGetMass()*3;
damping = strength/3;

in my on_rez for the rocket.