Jump to content

llSetForce fails on attachment unless I move


Vulpinus
 Share

You are about to reply to a thread that has been inactive for 2315 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I'm trying to use llSetForce to maintain a maximum altitude when flying. Simple enough it would seem, and it works well except when I'm not moving horizontally.

What I mean is that if I stop still, I can then move up using pg-up, above the set altitude, and the llSetForce does not push me back down. I can sit there all day at 110m when it's supposed to kick me down to below 100m, unless I just move a touch forward. Then I plummet as expected. This is the relevant script excerpt:

 

timer() {
	float MaxAlt=100.0;
	vector p=llGetPos();
	if (p.z>MaxAlt) {
		llSetForce(<0.0,0.0,-50.0>,FALSE);
		llOwnerSay("Yep");
	}
	else {
		llSetForce(<0.0,0.0,0.0>,FALSE);
		llOwnerSay("Nope");
	}
}

Yes, there's more code than that but I've narrowed it down to this in testing. When I'm at 110m, as confirmed by the viewer coordinates and debug output of p.z, my chat is screaming 'Yep' at me. But, I don't move down until I twitch forward a little. Then I drop to 100m or just below depending on when the timer catches me and removes the force.

I'm flummoxed. This is killing what I'm trying to do. Is this a known bug?

ETA: I'm not using TakeControls and there are no other forces interfering with things. I really have isolated it all down to the above testing modification of the script with most stuff commented out. Everything else is working (speed control and altitude control using llSetForce) as expected. Just not when I stop.

Also - is there a way to determine flying vs hovering? I'm guessing it's just done by detecting velocity in the script since I can't find any function for it.

 

Link to comment
Share on other sites

AGENT_FLYING is TRUE whether you are flying or hovering, so that won't help, and AGENT_IN_AIR detects whether you are falling.

Have you tried using llApplyImpulse instead of llSetForcellSetForce applies a continuous force, which doesn;t sound like what you want to re-apply each time the timer is triggered.  llApplyImpulse is instantaneous.

Link to comment
Share on other sites

Yes thanks, I've tried using llApplyImpulse over the last few minutes for the above-altitude correction. I used a sliding scale based on the difference and that works well so far for a quick return without overshoot.

I was using llSetForce for speed control so it seemed obvious to leverage it for the altitude control as well. Adding the impulse adds a little extra to the code and I was trying for a really quick timer function. I'll have to work on optimising things more.

I'm still really puzzled why it simply fails like this. I've tried several permutations of applying the force when above the ceiling, but it never works unless I move. Weird!

ETA: (I'll have to stop doing that)...

I still use llSetForce for altitude correction within the main speed control and that works perfectly. As long as I don't stop... then I need the additional Impulse method.

Link to comment
Share on other sites

I've just found a JIRA case which is the exact opposite of mine; force not being applied to move forward unless move up is pressed. Seems there is something fishy going on with llSetForce that causes it to fail when hovering. Typical!

Link to comment
Share on other sites

as far as I can remember this has always been the case since about 2005 maybe 2004 ? dunno exactly

it had to do in part with the greifing of new people at no-build WAs back in the day

like give them an attachment. Social engineer them to wear it (some shoes, hair, etc) and they are orbited instantly as soon as its worn. Which back in the day typically resulted in a viewer crash

the design thought process is/was that the act of moving our avatar is a voluntary thing and not involuntary. That we volunteer to move when we press a movement key

that when given an attachment that can orbit us, then if we don't volunteer (dont touch the keyboard) then we can more easy detach it

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2315 days.

Please take a moment to consider if this thread is worth bumping.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...