Pete Littlebird
Registered User
Join date: 30 Sep 2009
Posts: 44
|
10-14-2009 05:59
I've made myself an AO which works fine on land. Now I want to swim. I'm using llWater to change the result of llGetAnimation appropriately, and this too works ok.
What I'd like to do now is to keep myself swimming on the surface of the water when I'm not flying but I am below sea level, and to find a way of reducing the flight speed when I am flying below sea level. Any suggestions?
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
10-14-2009 06:20
ll water gives you the height of the water at the XY coordinates where the script calls the function, you would simply add probably quarter meter or so to that height so that the ao continues to swim at the surface.
float WHeight = llWater(ZERO_VECTOR) + 0.25; vector mypos =llGetPos(); if(mypos.z <= WHeight) { do the underwater ao }
and to slow your speed, i think you would use llSetForce
something like
vector velocity = llGetVel(); llSetForce((-velocity)/2,FALSE);//changes the velocity to a negative value, and then cuts it in half
to remove the force, simply
llSetForce(ZERO_VECTOR,FALSE);
|
Pete Littlebird
Registered User
Join date: 30 Sep 2009
Posts: 44
|
10-18-2009 05:20
Sorry for the delay in thanking you, Ruthven. It's turning out to be quite fun figuring out how much force to apply, and under what combinations of circumstances to do so 
|
Abune Audebarn
Abune Clocks & Lamps
Join date: 15 Aug 2009
Posts: 11
|
10-19-2009 16:54
I use llSetHoverHeight() in a swimmer AO, to keep the av on the surface during normal swimming. It's far easier than trying to figure out anti-grav forces.
For below-surface swimming it's not so good, but I'm still working on that and haven't had time to figure out the best method yet.
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
10-19-2009 18:39
does llSetHoverHeight actually work in attachments? and i'm not sure it's really needed for this is it? cause i assume all you're wanting to do is check if the avatar is above, below, or level with the water to decide what anim to play
|
Abune Audebarn
Abune Clocks & Lamps
Join date: 15 Aug 2009
Posts: 11
|
10-19-2009 18:53
Ah, good point. The swimmer I made is in OpenSim, not SL, and most physics commands there don't work on avatars through attachments, or at least didn't when I worked on it. Sorry, I should have mentioned that. Anyway, as a result, it's not an attachment, but a sit-on, kind of like a basic vehicle.
Nevertheless, it does a good job. Your main problem with surface swimming is not the animation to play, but maintaining height. I use the same animation for surface and underwater swimming; above water's not a problem, since that lies outside the whole "swimming" thing - in fact, you turn it off if you want to fly.
It's much simpler and more efficient to set your hover height to around the surface of the water and forget about it than to futz around with anti-grav forces and so on just to maintain the illusion of bouyancy. (Note that there's also a llSetBuoyancy() command, which I didn't use.)
EDITED TO ADD: I've just noticed that we seem to be working under different assumptions. Mine is that the AO modifies walking behaviour; the OP seems to be modifying flying behaviour. Obviously, the one I made does neither, but I was thinking of a walking situation in which the body would tend to drop to ground height; I probably made that assumption mainly because that's more like the speed you'd swim at. I don't know how llSetHoverHeight() would affect flying behaviour.
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
10-19-2009 19:57
i have a werewolf AO that automatically switches to swimming animations when i go below the water level. doesn't matter if i'm walking, running or flying, it plays the swimming animation.
as far as maintaining a height when flying, i'm not sure. i guess you could use llMoveToTarget, and update it constantly to move to water level
{ float water = llWater(ZERO_VECTOR); vector mypos = llGetPos(); vector target = < mypos.x,mypos.y,water >; llMoveToTarget(target,0.5); }
|
Pete Littlebird
Registered User
Join date: 30 Sep 2009
Posts: 44
|
10-20-2009 01:29
I'm working on the idea that when in the water, walking and standing states should be interpreted as surface swimming, and flying states should be interpreted as underwater swimming.
I'll have a look at llSetHover height and llMoveToTarget the next time I play with this code. Some sort of buoyancy is needed for surface swimming, but is generally unhelpful (though more realistic) underwater, where the main consideration seems to be reducing flying speeds to more realistic underwater swimming speeds.
|