Hi.
Long story short, I'm stuck on a script that supposed to make an object move backwards via TranslateTo to a certain point. Then, once the translation is complete, it's supposed to move the object (which is a static object) back to its starting position, or at least another set of coordinates and then have the object do it again and again as long as the cell is loaded.
Here's the issue that I keep running into; the object won't return to its start position, and even though I've had some help, I just can't the object's movement to loop as SetPosition will not fire after TranslateTo has acted on an object.
Here's the code:
Spoiler
Scriptname ___ZugImUnterfuhrung extends ObjectReference
;FOR THE RECORD, this script is attached to the object I'm trying to make move around.
;ALSO, I know this isn't elegant. I just want the thing to work first. Elegance can come later once something actually works right.
Event OnCellLoad() ;this gets things going when the cell loads
OnTranslationAlmostComplete()
EndEvent
Event OnUpdate() ;this perpetuates it, since I'm using an update loop
OnTranslationAlmostComplete()
EndEvent
Event OnTranslationAlmostComplete() ;the event that actually does the moving.
int END = 1152 ;the X Value that this thing is supposed to wind up at before cycling back.
if Is3DLoaded() ;checks to make sure the object is actually 3D-loaded.
TranslateTo(END, GetPositionY(), GetPositionZ(), GetAngleX(), GetAngleY(), GetAngleZ(), 1000, 0.0) ;The actual translation. Everything up to here works.
endif
EndEvent
Event OnTranslationComplete() ;THIS is where things go wrong. In past script iterations, I had a debug message box in here, which did go off, so I know this event triggers.
int START = -8832 ;This is the initial start position I want the thing to go to.
disable() ;this should turn it off, but for some reason this doesn't work.
setPosition(START, 0, 0) ;this should move it back to the location, but this also doesn't work.
enable() ;and I'm assuming that this also doesn't work, since disable wouldn't either.
registerForSingleUpdate(0.1) ;this did work though as the script did update.
EndEvent
If someone could please tell me how to get an object to move to a point after it has implemented "TranslateTo", I'd appreciate it, as once an object has been affected by "TranslateTo", all other functions seem to not work on it.
Also, if the script title didn't give it away (Ich sprechen ein bisschen Deutsch), I'm trying to make a subway tunnel, akin to the Blackreach Railroad mod. When the player is inside the train cab, they'd be able to look out at the tunnel, which appears to be moving passed them. What's really going on is that the sections of tunnel are moving backwards from one end of the train to another, and then, afterward, are "teleporting" back to their starting position only to repeat the procedure again and again.
I'm THIS CLOSE to having it working, but the problem is that I just haven't been able to get these blasted tunnel segments to return to their original positions.