Herding behaviour in animals in Second Life

I've been imagining an ideal Second Life horse.    How does it behave?  Its a real huge problem to make a herd move around.  Do the animals know each others places and avoid each other?  Do they shift about?  What happens when they run, do they form a line?  How do they navigate corners?  Climb?   Fly?   Do they moo, or whinny?  Lots of fascinating questions.    I've been doing a lot of head scratching on this one.....  It appeals to the analytic in me... 

Here is a picture of a dozen unicorns that need herd behaviour:


I came to the conclusion that the ideal equine would be a cube, and in a vacuum.    Sounds just like SL!

I booted up my herd prims last night...  it took a lot of tweaking of the physics, and the cube horse worked great!  But when I made it into a real horse, the horses were bouncing around like you could not believe...  but eventually I got them smooth. 

And of course, the inevitable happened.. I reset one script, and the prim it was in fell thru the platform I was one, so in a panic I sweep-grabbed it and brought the prim back up.   When I looked up, all the horses were gone!They had chased the prim below the platform.. and then a few seconds later they came rising straight up out of the ground like angels..  and hovered there until I moved the rescued chaser prim back on the ground.  I moved the prim around from spot to spot in small motions and they dived and swooped like birds.

So yeah, you can have unicorns dance in mid-air....  and swoop around like at the Unilympics in the Blue Adept "Split Infinity" novels by Piers Anthony.

Herding behaviour is a fascinating subject.     They won't like climbing anything steep.  Any climbing up and down will cause  the animals in the back to rise up off the ground in the V-valley...  I think that would be a good place to run, as it fools the eye...  I will shrink the spacing in a bit when the Z axis changes.    They need meters of space... I will shrink the side by side offset too, as they speed up.  They can foirm a line when they run. 

So lets get back to herds and herd behavior.   Herd have feelings.   Imagine that the mare on the left likes to keep her right eye on that mean mare on the right side, and she likes to follow the stallion, so she tends to be behind and to the left of him.  The Stallion, of course, tends to steer the herd.   He turns sharply, and leads, and the rest catch up.  He is in front of where the herd is going.  The mares don't really follow him. In reality,  they follow a spot behind him, where they want to be, and he is "in front of" that spot.   Each herd animal follows their own spot behind the stallion.  Its like the center of gravity of an airplane.  The plane does not "follow the nose".  The nose leads the center of gravity of the airplane, which is about 1/3 of the way back behind the wings front.   The plane balances on that spot.   I think herds do the same.

So I set out to model it.

Now think if a skier and a rope behind a boat..  Or think of Mach's boat ( from the book) with a rope and a horse or unicorn on skis.

All I had to do was to add one number (a vector) to the location of the CG of the herd.  There is an invisible prim at that spot.   All you do to set up a herd is to edit a unicorn,  change the Description to something like <5,5,0>, and that equine will immediately head for a spot 5 meters to the left and behind the CG prim.   

Look at Horses 1,2, & 3 below.  These want to follow the white arrow around to all the black squares.   The arrow turns sharply at each black corner square.  The herd turns sharply as a result.   To fix this, So I have the herd maintain their positions not just to where the arrow is, but also to want to turn in the same direction as the arrow is at any moment.  Just like a skier being dragged screaming behind Ferd and Waving girl in a Mach's boat.

When the blue arrow (shown below) suddenly changes direction, the white animals suddenly want to be where the red horses are, so they make a left turn, not a right!

But the arrow has already moved on, so they curve back to the right.


Now think of a negative length rope attached to the CG of the herd.....  It is the stallion, out in front of the herd, leading the way.   He turns sharply inward when the arrow rotates, and when you watch this in SL, it all looks like a herd!

Addition of two numbers.. who'd a thunk it did that?

Ferd Frederix