Game Development Community

There seems to be a problem with images and triggers....

by John Carroll · in Torque 3D Professional · 08/03/2011 (3:56 pm) · 12 replies

The following block of code appears to be in error:

// Replicate the trigger state into the move so that
   // triggers can be controlled from scripts.
   for( int i = 0; i < MaxTriggerKeys; i++ )
      movePtr->trigger[i] = getImageTriggerState(i);

This block can be found in aiplayer.cpp at line 407. MaxTriggerKeys is defined as 6. In getImageTriggerState the argument is a slot number. There are only 4 slots, and this loop assumes 6. What gives? The comment notwithstanding, what are we trying to do here? The problem is that when we call with i = 4, we index beyond the end of the array, and the value returned is true. This in turn causes us to think that our pose should be prone, as it appears that trigger[4] is used for that purpose.

About the author

Working on using Torque as an Image Generator for Tactical Simulations under laser and live fire conditions, for Law Enforcement/Military applications.


#1
08/04/2011 (1:26 am)
It seems that you have found the cause of a problem which exists for a while. Everytime I spawn an AI with a prone-anim it starts proned, because trigger[4] is 1.
#2
08/04/2011 (6:30 am)
Ah, that probably explains why 'prone' was never fully implemented....as a stock movement.
#3
08/04/2011 (7:05 am)
I'm pretty certain that the "prone on start" issue was worked out since 1.1B3.
#4
08/04/2011 (8:22 am)
@Steve:
Unfortunately it didn't.
#5
08/04/2011 (8:42 am)
You do have a get/set pose for Ai? Else they're not going to be getting the correct info to replicate the pose triggers.
#6
08/04/2011 (9:23 am)
@Steve:
I am working on it, but it will take some time.
#7
08/04/2011 (9:31 am)
I'll post a resource
#9
08/04/2011 (9:48 am)
Well, thank you for the resource, but I notice that we still attempt to read beyond the end of the image array...this array in my code is set to 4, while the number of triggers is set to 6. This appears to be benign, since we are just reading it, but we are reading garbage once i > 3. (Bad form, I guess).
#10
08/04/2011 (12:25 pm)
Thanks Steve, this might do the trick.

@John:
Just read the first 3 triggers with getImageTriggerstate and with the resource Steve posted a link to, the problem must be solved.
#11
08/04/2011 (3:49 pm)
for( int i = 0; i < MaxTriggerKeys && i < maxMountedImages; i++ )
(I think MaxMountedImages is the name of the constant...)

This code/bug has been around for a while... I suspect it's intended to allow you to call setImageTriggerState on AIPlayers and not have them reset it every tick.
#12
08/04/2011 (3:50 pm)
Ok, that's fine, again, it looks to be a benign read, just seems wonky. The work around works fine for us for now. Thanks to all who posted responses to this thread!!!