Da Fish in Sea

These are the voyages of Captain Observant

Pointing at Something in 3D

| 2 Comments

After I did the example yesterday of the many fish scattered across the screen, it seemed rather sad that they were not moving, so I set about making them move. I want them to also point in the direction of their movement, and in looking over the docs, I found a method of Matrix3D called pointAt(). This sounded promising, and I kindof got it working, except that now my fish had infinite height… Not a pretty sight let me tell ya. I don’t know what caused this ‘glitch in the matrix’ but when I saw that Utils3D also had a similar method called pointTowards, I thought I’d give that a go. Not expecting any difference, I was thrilled to see that it actually worked. I did also have to fiddle with obtaining the target matrix value, as it apparently has to be relative to the matrix we are manipulating. Anyhoo, enough chatter (you can read the code if you’re interested, though I must apologize for the lack of comments , which I intend to remedy later) – here is the result:

flash 10 required

Da Code

FishPointTarget.as

FishPoint.as