Hope you enjoyed restful Christmas and New Year break.
I have experienced rather strange behaviour in my NPC storytelling system. Certain jGPU character models are not moving or rotating to specified coordinates; and others are.
The first suspected cause of this problem was some kind of mistake made in the NPC class. I was 100% certain of this because of the clue highlighted in blue below. But now I am only 50% sure the problem is coming from my code because of the clue highlighted in red.
Here is what is happing in my system.
I obtain a new position in an animation and assign it to each actor in a scene. -
If the actor is set as the NPC speaking to the player as part of a conversation, the actor successfully moves to the correct position - If the NPC is not set as the one speaking prior to initialization, the NPC does not move to the correct location.
Therefore, the following line of code works only on the NPC set as the speaker in the conversation. Which points to an issue in my code. There are only a few calls to AnimObject_SetPosition; the call for an actor to be repositioned, and a call for the players/dynamic-entities to be repositioned. The last call to AnimObject_SetPosition, per camera, prior to each camera render is the on the actors, that which are the subjects of this concern.
AniObjs(ani).Actor.X# = x#
AniObjs(ani).Actor.Y# = y#
AniObjs(ani).Actor.Z# = z#
....
x# = AniObjs(id).Actor.X#
y# = AniObjs(id).Actor.Y#
z# = AniObjs(id).Actor.Z#
...
AnimObject_SetPosition ob, X#, Y#, Z#
Here is where things get really spooky, and is the reason I require your insight in finding the root cause of the problem. The following line of code was used to apply a sine wave movement to the non speaking NPC, the ones which do not move as expected.
AnimObject_SetPosition ob, x# + Sin(HiTimer()), y#, z#
It turns out the character indeed moves from side to side in a sine wave motion, but from the wrong location; at the characters spawn location, and not the location indicated in my scene timeline.
To clarify, given a standard dark basic object, and an AnimObject, as was used in a test I performed; the dark basic object would move to the correct location, but the AnimObject would not.
To make things even more spooky, both objects,
given the same coordinates from the same variables in the same block of code with the addition of a sine wave value; both objects would move from side to side, but the AnimObject character moved from its spawn location, and not the location assigned to it. Throughout the lifetime of the character AnimObject after action starts, nothing appears to assign the character's position to its spawn location.
If that result was not demon possessed enough, get this; the AnimObject_GetPosition returns the location assigned to the character object, the correct location; but the character did not move; or rotate.
Dark Basic U77 - The previous version, and current version of the jGPU plugin
Have you ever experienced any situations where given a series of AnimObjects got positioned and rotated by the set position/rotation commands, and not others?
It appears that have either made a very dreadful mistake in my code, which I have been searching for a number of days; or there is some kind of conflict coming from some kind of iteration or variable assignment block in the plugin code, causing the wrong AnimObject to move.
It would take days, possibly weeks for me to reproduce the error in small program which I could share with you, especially when I am not sure what part of my code could be at fault. There are database parsers, diagram parsers, .NET dlls and Blender scripts involved.
I will continue to look for clues. There a number of further tests I am preparing. If you have any ideas of tests I should perform, it would be really helpful.
Have a good day.