YouDoNotKnowMyName Posted December 8, 2021 Share Posted December 8, 2021 Good morning everybody! I am just trying to move and rotate a static object with a script, nothing fancy.(It is supposed to be a secret door / trap that opens when the player enters a triggerbox) But it does not work. The object just stays in its original position for a few seconds and then suddenly pops to the new position/rotation.It should not do that. I just used the "TranslateTo" function with a speed of 10.0 (set as a property so I can change it without needing to edit the script)Also this is the first time I am messing around with "states".(They would not be needed for something simple like this, but once I get this to work, this script will become more complex, so they will be needed) Scriptname GI_RotatingChamberTrigScript extends ObjectReference {Script that rotates and moves the chamber to the open position when the player gets near.} ObjectReference Property RotatingChamber Auto {The actual chamber that gets rotated, a custom static mesh} ObjectReference Property ClosedPosition Auto {Marker that defines the closed position} ObjectReference Property OpenPosition Auto {Marker that defines the open position} Float Property MovementSpeed Auto {The speed at which the chamber rotates} auto state ChamberClosed ;the initial state endState state ChamberOpening ;the chamber is opening, ignore any triggers event OnTriggerEnter(ObjectReference akActionRef) ;do nothing, the chamber is currently opening endEvent endState state ChamberOpen ;the chamber is open, ignore any triggers event OnTriggerEnter(ObjectReference akActionRef) ;do nothing, the chamber is open already endEvent endState ; Have the event run if the triggering objectreference is the player. Event OnTriggerEnter(ObjectReference akActionRef) if akActionRef == Game.GetPlayer() ; player entered the triggerbox ;open the chamber GoToState("ChamberOpening") RotatingChamber.TranslateTo(OpenPosition.GetPositionX(), OpenPosition.GetPositionY(), OpenPosition.GetPositionZ(), OpenPosition.GetAngleX(), OpenPosition.GetAngleY(), OpenPosition.GetAngleZ(), MovementSpeed, MovementSpeed) GoToState("ChamberOpen") endif EndEvent Link to comment Share on other sites More sharing options...
RoNin1971 Posted December 8, 2021 Share Posted December 8, 2021 Why not 'simply' use a animated nif (as activator) for your door? (i could help you out on that) Link to comment Share on other sites More sharing options...
YouDoNotKnowMyName Posted December 8, 2021 Author Share Posted December 8, 2021 Why not 'simply' use a animated nif (as activator) for your door? (i could help you out on that)Because I don't want to ...And because I haven't finished the actual mesh yet, I am currently just using a "placeholder mesh".And with a script doing everything, I can switch out or change the mesh however I want without having to redo the "animation" or messing around too much in 3dsmax. That is kind of my workflow for custom asset stuff:First I just create a simple "placeholder mesh" that I just use to actually see how it will look in the game in terms of proportions, placement, ...That placeholder mesh does not have any proper UV mapping, just the automatic UV mapping that 3dsmax does and just some vanilla texture. Then when I feel like "yes, this will work" I will actually make the proper mesh, with proper UV mapping and texturing.And I don't need to change anything in the CK, I just need to replace the nifs. Link to comment Share on other sites More sharing options...
DieFeM Posted December 8, 2021 Share Posted December 8, 2021 (edited) Make sure that your property is actually being filled with a conditional statement before working with it, e.g. "If RotatingChamber", and also use a debug notification, message or trace so you know what's going on in case of failure.There could be several reasons why it could return none and fail translating, using a saved game in which this script had different properties being the most common mistake when your developing/debugging scripts.If there's the possibility that your object have no 3d loaded when this translation starts, or it is in its way to load (because you just spawned it), put your translation inside of If WaitFor3dLoad() statement to make sure it is loaded when it starts translating, in this same statement you can use an "else" statement for debugging, and register for OnLoad on this reference as, so you make sure its 3d is fully loaded, otherwise the translation will not start. On the other hand, TranslateTo will not wait for the translation to end before trying to run the next function call in your script, you need to register for (RegisterForRemoteEvent) OnTranslationComplete and change to ChamberOpen state there. Edited December 8, 2021 by DieFeM Link to comment Share on other sites More sharing options...
YouDoNotKnowMyName Posted December 8, 2021 Author Share Posted December 8, 2021 No, I am not using a savegame to test this, I am COCing into that cell (it is an exterior cell).Yes, the object is loaded when the translation begins.Yes, the property is actually filled. It does the translation thing, it just does not show it.(Because the object "pops" into the position that it should have after the translation, if it did not translate then it would just stay in place forever) I set the "OnTriggerEnter" event to do nothing just before starting the translation, so any "player enters the triggerbox again" events will be ignored while the translation is ongoing.That is all I care about for now, I will worry about the other stuff later ... Link to comment Share on other sites More sharing options...
pepperman35 Posted December 8, 2021 Share Posted December 8, 2021 Have you considered using the rotatehelper and/or platform helper on your trap door. Link to comment Share on other sites More sharing options...
DieFeM Posted December 8, 2021 Share Posted December 8, 2021 It does the translation thing, it just does not show it.(Because the object "pops" into the position that it should have after the translation, if it did not translate then it would just stay in place forever) That's different problem then, by changing the motion type to keyframed right before starting the translation it should work: RotatingChamber.SetMotionType(RotatingChamber.Motion_Keyframed) Link to comment Share on other sites More sharing options...
YouDoNotKnowMyName Posted December 8, 2021 Author Share Posted December 8, 2021 It does the translation thing, it just does not show it.(Because the object "pops" into the position that it should have after the translation, if it did not translate then it would just stay in place forever) That's different problem then, by changing the motion type to keyframed right before starting the translation it should work: RotatingChamber.SetMotionType(RotatingChamber.Motion_Keyframed)That worked!Thanks so much! Now it is moving like it should! Link to comment Share on other sites More sharing options...
RoNin1971 Posted December 9, 2021 Share Posted December 9, 2021 Why not 'simply' use a animated nif (as activator) for your door? (i could help you out on that)Because I don't want to ...And because I haven't finished the actual mesh yet, I am currently just using a "placeholder mesh".And with a script doing everything, I can switch out or change the mesh however I want without having to redo the "animation" or messing around too much in 3dsmax. That is kind of my workflow for custom asset stuff:First I just create a simple "placeholder mesh" that I just use to actually see how it will look in the game in terms of proportions, placement, ...That placeholder mesh does not have any proper UV mapping, just the automatic UV mapping that 3dsmax does and just some vanilla texture. Then when I feel like "yes, this will work" I will actually make the proper mesh, with proper UV mapping and texturing.And I don't need to change anything in the CK, I just need to replace the nifs. Yeah I guessed as much already. Its a verry interesting approach for sure :thumbsup: Link to comment Share on other sites More sharing options...
Recommended Posts