Problem with GetObjectVisualTransform
NeverwinterWights
Member Posts: 339
I started messing around with this new function and ran into a problem (or maybe me just not using it right) right away. In testing I set down a placeable object (TEST_TRANSFORMER). And then used a control panel with, what I thought would be a simple script, to simply move the object on x axis. Here's the script on the control panel:
So it works fine but only once. You use the control panel and the test object moves. When you use the control panel again the test object won't move. In addition when you go to click on the test object that just moved, your character will go to the original location of the test object, instead of where it is currently located, and try to use it. Am I just not using the function right or is this still a known bug? I did put in a little bit of debug stuff just to make sure the object still existed.
void main()
{
object oPC = GetLastUsedBy();
object oTransformer = GetObjectByTag("TEST_TRANSFORMER");
//int iUseable = GetUseableFlag(oTransformer);
//SendMessageToPC(oPC, "Is Useable: " + IntToString(iUseable));
if (GetIsObjectValid(oTransformer))
SetObjectVisualTransform(oTransformer, OBJECT_VISUAL_TRANSFORM_TRANSLATE_X, 5.0);
else
SendMessageToPC(oPC, "Object not found");
}
So it works fine but only once. You use the control panel and the test object moves. When you use the control panel again the test object won't move. In addition when you go to click on the test object that just moved, your character will go to the original location of the test object, instead of where it is currently located, and try to use it. Am I just not using the function right or is this still a known bug? I did put in a little bit of debug stuff just to make sure the object still existed.
0
Comments
void main() { object oPC = GetLastUsedBy(); object oTransformer = GetObjectByTag("TEST_TRANSFORMER"); float fCurrentTransform = GetObjectVisualTransform(oTransformer, OBJECT_VISUAL_TRANSFORM_TRANSLATE_X); if (GetIsObjectValid(oTransformer)) SetObjectVisualTransform(oTransformer, OBJECT_VISUAL_TRANSFORM_TRANSLATE_X, fCurrentTransform + 5.0); else SendMessageToPC(oPC, "Object not found"); }
It's just odd that once you move something you can't "use" it correctly anymore, at least not at it's new position. I guess the object isn't "really" there. Just a copy of the object?
If you remove the visual transform I think the object will return to the original position.
So if you want to increase the offset you'll need to calculate the new offset like you did in the second post, otherwise the offset remains the same, relative to it's position.
http://www.purplemath.com/modules/fcntrans.htm
https://www.mathsisfun.com/geometry/translation.html
So not a problem with the function. Just what I was imagining it to be.
To create the bookcase secret door, for example, you'd need a bookcase placeable with no walkmesh for the visual part, and invisible barriers in the doorway and at the "open" position of the bookcase, toggled by script for the walkmesh part. Easily done.
For creatures, there are similar limitations. The good news is that even part-based creatures scale nicely, hold weapons and perform combat animations correctly. The (not very) bad news is that pspace (which controls clipping) doesn't scale, and some node-related activity such as turning in conversation doesn't take account of rotation. All these things can be tweaked or suppressed.
The only really strange thing I found with creatures is the animation speed. When the creature is walking or fighting, its body parts are no longer joined up (try it for fun!). I doubt whether this is a bug, just a limitation.
-JFK
https://www.youtube.com/watch?v=yXy1VN1M4ZY
int iInt; void Locomotion(object oObject, int iTransAxis, float fTransDistance, int iIterations, float fDelay) { if (iInt < iIterations) { float fCurrentTransform = GetObjectVisualTransform(oObject, iTransAxis); SetObjectVisualTransform(oObject, iTransAxis , fCurrentTransform + fTransDistance); iInt++; } DelayCommand(fDelay, Locomotion(oObject, iTransAxis, fTransDistance, iIterations, fDelay)); } void main() { object oPC = GetLastUsedBy(); object oTransformer = GetObjectByTag("TEST_TRANSFORMER"); object oTestChain = GetObjectByTag("TEST_CHAIN"); object oTrapDoor = GetObjectByTag("SECRET_TRAPDOOR1"); int iUseable = GetUseableFlag(oTrapDoor); SetUseableFlag(OBJECT_SELF, FALSE); DelayCommand(7.0, SetUseableFlag(OBJECT_SELF, TRUE)); PlaySound("al_cv_millwheel1"); if (!iUseable) { Locomotion(oTransformer, OBJECT_VISUAL_TRANSFORM_TRANSLATE_Z, 0.03, 70, 0.1); Locomotion(oTestChain, OBJECT_VISUAL_TRANSFORM_TRANSLATE_Z, 0.03, 70, 0.1); DelayCommand(7.0, SetUseableFlag(oTrapDoor, TRUE)); } else { Locomotion(oTransformer, OBJECT_VISUAL_TRANSFORM_TRANSLATE_Z, -0.03, 70, 0.1); Locomotion(oTestChain, OBJECT_VISUAL_TRANSFORM_TRANSLATE_Z, -0.03, 70, 0.1); SetUseableFlag(oTrapDoor, FALSE); DelayCommand(2.0, AssignCommand(oTrapDoor, PlayAnimation(ANIMATION_PLACEABLE_CLOSE))); } }