Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

how to turn of flying?

FEZ Rutherford
Registered User
Join date: 9 Dec 2003
Posts: 14
09-20-2006 03:36
Hi...
Is there a way to turn off flying from a scripted attachment?

So if I am currently flying and put on the attachment, it turns of flying so i fall down to earth?

FEZ
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
09-20-2006 04:22
From: FEZ Rutherford
Hi...
Is there a way to turn off flying from a scripted attachment?

So if I am currently flying and put on the attachment, it turns of flying so i fall down to earth?

FEZ



Do you mean you want to do that or thats what it currently does?
FEZ Rutherford
Registered User
Join date: 9 Dec 2003
Posts: 14
09-20-2006 04:26
I want to do it?
I just don't know how to achieve it... :-(
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
09-20-2006 05:28
Not directly, but you could have one that applied a downwards force if the avatar was flying. Something like this...

CODE
integer gFlying = FALSE;

default
{
attach(key id)
{
if (id == llGetOwner()) {
// Start timer to check for flight when attached
llSetTimerEvent(0.1);
}
else {
llSetForce(ZERO_VECTOR, FALSE);
llSetTimerEvent(0.0);
}
}

timer()
{
integer flying = llGetAgentInfo(llGetOwner()) & AGENT_FLYING;
if (flying) {
if (!gFlying) {
// When start flying, impose a downward "gravity" force
// since SL won't be applying one
llSetForce(<0.0, 0.0, -9.8 * llGetMass()>, FALSE);
gFlying = flying;
}
// Cancel out avatar's upwards movement
vector vel = llGetVel();
llApplyImpulse(<0.0, 0.0, -vel.z> * llGetMass(), FALSE);
}
else if (gFlying) {
// Release downward force
llSetForce(ZERO_VECTOR, FALSE);
gFlying = flying;
}
}
}
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
09-20-2006 06:50
May need to also check AGENT_IN_AIR in case they are hovering?
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
09-20-2006 07:33
If they're hovering, I'm pretty sure that AGENT_FLYING is still on; I did a parachute script that only slowed you down when you were in the air and not flying recently using that. I might have forgotten though.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
09-21-2006 00:55
From: Ordinal Malaprop
If they're hovering, I'm pretty sure that AGENT_FLYING is still on; I did a parachute script that only slowed you down when you were in the air and not flying recently using that. I might have forgotten though.


Reread the wiki and you're right, its jumping etc., not hovering that clears the FLYING flag. My mistake.