Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Realistic fish movement?

Lordfly Digeridoo
Prim Orchestrator
Join date: 21 Jul 2003
Posts: 3,628
08-14-2004 16:10
Howdy. Some of ya'll might know me as the motormouth in the other forums, and a prim pusher in-world.

Well, I finally picked up the LSL scripting language (thanks Wiki!), and started doodling with some personal projects that I've been wanting to do for the last year.

For instance, I just have completed the initial scripts for a randomly moving fish within a fish tank.

I'm using LLMoveToTarget, randomly moving to random points within the confines of the fish tank. It works pretty well, except for some minor problems.

Basically, the fish does move around pretty well spatially, but it doesn't act like a fish would.

I guess what I'm trying to ask is if anyone has some decent techniques for realistic, random, organic movement, such as a fish?

If you need a visual explanation, check out my beta fish tank in south Grignano (inside the big brick studio apartment building thing).

Any help would be appreciated.

:)

LF
_____________________
----
http://www.lordfly.com/
http://www.twitter.com/lordfly
http://www.plurk.com/lordfly
Saaz Roentgen
Minifig
Join date: 30 Aug 2003
Posts: 14
08-14-2004 19:35
Truk Godel (I think that's his name) was working on fish a few months ago. I don't know if he's still an active player, I haven't seen him for a long time.

I've thought about doing fish, but haven't gotten around to any actual coding, so I'll give you a little brain-dump of what I've thought about.

Based on RL observations of my own fishtanks, there are different kinds of fish. Some school, some are bottom-feeders, and scurry around the bottom, some like to swim back and forth in open space, some are inquisitive, always swimming around looking at everything trying to find food, etc

I know you're probably asking for an algorithm, and I'm getting off-track here... But I guess to try to make this useful: different fish behave differently- if you just narrow down the movement a bit, keep the fish in the top half or the bottom half of the tank, it might look more realistic vs having the fish randomly move all over.

For the inquisitive food-hunter type, if you have any objects in the tank, I bet you could just have the fish go point-to-point, pausing and "looking" at all the objects, and it would come off pretty well. Especially if you randomize the order, so it's not just making a consistent circuit.

For schooling fish I would look for a "flocking" algorithm. I'm too lazy to do a search, but I think I remember one being posted not long ago.
_____________________
I would kill everyone in this room for a drop of sweet beer.
Wraith Jensen
I can walk thru walls....
Join date: 8 Aug 2004
Posts: 130
08-14-2004 23:21
How funny.

I got an underwater plot, and I was thinking of putting fish in it.

Let us know what happens.
_____________________
Catfart Grayson
Registered User
Join date: 16 May 2004
Posts: 264
08-15-2004 04:06
I'm quite pleased with the movement I've manged to get on my fish. Take a look at them in Fujin (Below the broken bridge) or at the market in the new Central View private sim.

You get a better random target selection by using two random numbers not one. lllFRand(3) + llFRand(3) givea a much better result (for the pruposes of simulating life) than llFRand(6). ITs also easier to fine tune the algorythm to produce different behaviours.

The actual movement itself is accomplished by a force moving the fish along its forward axis, a torque force to try and turn the fish axis towards the target and a regular impulse pushing against the fish's global movement to act as fiction. The result is the fish turns and moves forward at the same time. In addition, its speed is not constant, which also makes it look more organic.

You have tweak the values to get the effect you want, too fast a fish with to o large a turning circle means that it willnever actually reach the target. Its quite easy to get things to orbit their target this way. Adjustment here can give you a fish that turns lazy circles arond its target or one that can double back on itself.
_____________________
Cat
Apotheus Silverman
I write code.
Join date: 17 Nov 2003
Posts: 416
08-16-2004 09:04
You can find my swarm script and related stuff here. It effectively allows you to create a group of objects that swarm/school/flock with customizable parameters.
_____________________
Apotheus Silverman
Shop SL on the web - SLExchange.com

Visit Abbotts Aerodrome for gobs of flying fun.
Remo Yossarian
Registered User
Join date: 15 Feb 2004
Posts: 121
08-16-2004 09:54
Someone had some fish that would actually wiggle their tails as they traveled through the water. These were the best I have seen to date.

You might be able to do it with a single prim fish then oscillating the rotation of the fish back and forth quickly as they move.
Wraith Jensen
I can walk thru walls....
Join date: 8 Aug 2004
Posts: 130
08-16-2004 09:59
I'm just going to make some single-prim fish, just enough to populate the water underneath my platform.

It's amazing how quickly 117 prims goes.
_____________________
Logan Bauer
Inept Adept
Join date: 13 Jun 2004
Posts: 2,237
08-26-2004 15:08
You could use an animated texture of a fish swimming frame by frame, and then put that onto your basic cardboard-cutout-flat fish with your rotation. Or, put an animated-texture fish onto Apotheus Silverman's swarm script, if you want to get really crazy. I plan on doing just that for the aquarium in my home when I get around to building it.