Scripting News Week 34

Working with Pathfinding I’ve needed to do some things I don’t normally do. Basically I avoid doing rotations as much as possible because I just have not gotten my brain around idea of Euler-Quaternion and why gimbal lock is a problem.

The new task I needed to accomplish is how to get my Pathfinding AI Character to look at someone in the area. We have lots of new functions that can be used to assist with that.

My Pathfinding Character

I looked at llLookAt(). This function points the positive Z-axis toward an agent or object. That creates an immediate problem because the llCreateCharacter() points the Z-axis up. I think one can rotate the Character to make the Z-axis horizontal, but that doesn’t work for my character that needs to be taller than it is wide.

The function llRotLookAt() looked to be a better choice. But the definition was so confusing I had a hard time using it. Searching the forum I found a couple of threads that explained the function and how it worked.  If I had started with those, I could have saved myself a load of time experimenting.

Innula Zenovka, Rolig Loon, Void Singer, and Strife Onizuka helped in various ways to get me straightened out. Void Singer and Strife Onizuka helped me get the wiki changed to provide a better definition of the function’s behavior… or maybe they just cleaned up the mess I made of it. Whatever, we have a better wiki page for llRotLookAt() and some of my stuff survived. 🙂

The best part is that I have llRotLookAt() working with my Pathfinding Character.

Example Scripts

There are a few example scripts of how to implement Pathfinding Characters. See: Pathfinding Example Scripts.

  1. For simple wandering characters: llWanderWithin_debugging
  2. For characters following a set coordinate path: llPatrolPoints_debugging
  3. For characters that avoid avatars: llFlee_debugging
  4. For path_update event: Path_update_debugging

The scripts have the code you’ll need to debug your characters. You WILL need to debug them.

Viewer Problems

The Beta and Development viewers have the Pathfinding Tools. You’ll need to look at the Navmesh to get an idea of why you character goes where it goes and why it dodges whatever it dodges.

I have found both of those viewers crash prone and …sticky… meaning the FPS and what I see on the screen seem out of sync. I have not yet found a way to reproduce the problem reliably and I can’t yet tell if it is my system or the viewer. But, Pathfinding (PF) Characters disappear in both. I’ll be clicking on a character and nothing is happening, then poof it rez’s someplace else. All the time the PF Character was moving. It only looked like it was stationary. Zooming in and out changes where the character appears. The parts of my 3 piece/prim character get strung out along the path and suddenly appear together farther along the path. It’s a mess.

It is not just my PF Character. Doors are doing something similar. I’ll click and open a door. But, it never moves. If I try, I can walk through the space where it appears to be. Also my cursor is no longer shows a click-hand over the door. If I move the cursor to where the open door should be, the cursor changes and I can click. Then sometimes I see the door poof open and start closing… it is very annoying using the Beta and Dev viewers for PF work… well much of anything.

I’ve been looking for an nVidia update, I’m on 301.42. NVIDIA is past due for a release, or so I think. There are not enough people using the PF Tool viewers for me see complaints appearing in the forum. So, I can’t really tell where the problem originates. Hopefully it will go away.

Gimbal Lock

I have been trying to understand what gimbal lock is. This video explains it.

Now I know WHAT it is. I’m just not sure what I can do with the knowledge.

I understand why I convert in and out of Euler. I just have trouble understanding some of Euler/rotation/vector math and why it works such that I can predict the results.

One thought on “Scripting News Week 34

  1. I ran into this a long time ago when animating in Poser. I wanted the arm to move from an up position in a straight line to a down position. I had rotated various parts of the arm, and unknowingly had hit gimbal lock. When I played the animation, the arm moved in a curve from up to down instead of in a straight line. Once I learned what gimbal lock was, I was able to change my animation to get the desired effect. Just wanted to let people know they might encounter this problem in animating the avatar, and I imagine several have already without knowing what is happening.

Leave a Reply

Your email address will not be published.