Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Kangeroo Hop

Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
12-11-2007 00:13
I'm trying to create a little script to make a 'Kangeroo Hop' (or 'Bunny Hop'). The following widely-avaliable freebie script called 'Bounce' almost exactly performs the movement I am looking for:

CODE


default
{
on_rez(integer x)
{

llResetScript();
}
state_entry()
{
llSetStatus(STATUS_PHYSICS,TRUE);
llSetStatus(STATUS_PHANTOM,TRUE);
llCollisionSound("c02681b3-52f3-dfa0-416b-3f414fb01aef",1);

}
land_collision_start(vector x)
{
llSetStatus(STATUS_PHYSICS,FALSE);
llSetPos(llGetPos() + <0,0,1.25>);
llSetStatus(STATUS_PHYSICS,TRUE);
}
}


The problem I have with this script is that it uses 'land_collision_start' and therefore only reacts to the ground. It can not be used on any other surfaces.

So, how can I recreate this movement but have it react to any (non-physical) surface under the bouncing object?

All my attempts so far have been either miserable failures, or have been too jerky to be convincing.

Thanks in advance!
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
12-11-2007 00:39
You may be better off using an ao and animation for this.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-11-2007 00:40
collision_start?
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
12-11-2007 14:35
You could monitor the objects vertical velocity component. When it switches from down to zero or up, that means it needs to hop again.

Or, set a timer and hop every so often. Physics will bring you back down.
_____________________
So many monkeys, so little Shakespeare.
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
12-12-2007 07:45
heyas;

try using a timer to flip buoyancy from 0 to 1 (or is that greater than 1 to float up?). this will make the object (and the person wearing it, if worn) float up and fall down. when they fall down, they'll just hit the ground/primfloor and land there.
_____________________
Why Johnny Can't Rotate:
http://forums.secondlife.com/showthread.php?t=94705
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
12-20-2007 11:29
Thanks for these suggestions.

After many dead-ends, and lots of miserable failures using llSetPos(), I have finally gotton a fabulous solution using llMoveToTarget(). I would never have guessed that such a seemingly simple movement like a "hop/bounce" would have proven so problematical.

In essence:

1) Confirm and store a Start Position

2) Set up a list of vector offsets from the Start Position:
a) the first offset in the list should be an offset of <0.0,0.0,0.0>
b) the second offset represents the hop-up and consists <llFrand(vector.x), llFrand(vector.y), llFrand(vector.z)>
c) the third offset represents the hop-down and consists <llFrand(vector.x), llFrand(vector.y), 0.00> (ie: no offset from the Start Position on the z-axis)
d) all subsequent EVEN numbered offset elements in the list are as b) (hop-up)
e) all subsequent ODD numbered offset elements in the list are as c) (hop-down)
f) the last offset in the list should be a hop-up

3) Set up llMoveToTarget() to cycle thro' the offsets in the list. The tau value is relatively low.

4) Play the "bounce" sound when processing one of the ODD numbered offset elements (hop-down)

5) Stop processing for a time, as I'm told 'Roo's jump in bursts, not constantly

6) During this time break, re-calculate all the vector offsets in the list, remembering that the first element should be an offset of <0.0,0.0,0.0>

7) Repeat from 3)

...and the result is a fabulous & realistic bouncing hop :)