Jump to content

Would Appreciate Some Scripting Help; setPosition does not work after TranslateTo


ZeroCore

Recommended Posts

  On 9/6/2016 at 6:44 AM, ZeroCore said:

 

  On 8/30/2016 at 5:12 PM, dalsio said:

 

Aha, I think I know why my code failed for you. It seems that I didn't take my own advice in accounting for if the translation failed, because from what I can tell your translations are in fact failing. Is there something in the objects way that is stopping them, or are there any other bits of code that's interacting with the objects? If they in any way stop the translation it will result in a failed translation and thus TranslateComplete() doesn't activate.

 

Regardless, this bit of code should cause the object to return to it's start position and translate regardless of whether it successfully translates or not. StopTranslation() is used here to make doubly sure the object isn't translating when setposition() is called, though that shouldn't happen.

 

Try this:

Scriptname ___ZugImUnterfuhrung extends ObjectReference

Int END = 1152
Int START = -8832 

Event OnCellLoad()
      Move() 
EndEvent 

Event OnTranslationComplete() 
      Move()
EndEvent

Event OnTranslationFailed()
      Move()
EndEvent

function Move()                     ;To be called on first load and on translation completion. 
      StopTranslation()
      setPosition(START, 0, 0) 
      Utility.Wait(0.1)             ;replaces delay previously set when registering for a single update
      if Is3DLoaded() 
            TranslateTo(END, GetPositionY(), GetPositionZ(), GetAngleX(), GetAngleY(), GetAngleZ(), 100, 0.0) 
      endif
endFunction

 

  On 8/30/2016 at 9:45 AM, NexusComa said:

in this script

 

MarkerREF.SetPosition(2560.0000,2560.0000,-1024.0000)

WaterREF.TranslateToRef(MarkerREF, 10.0)
While(WaterREF.GetPositionZ()!=(-1024.0000))
Utility.Wait(2.0)
EndWhile
WaterREF.SetPosition(2560.0000,2560.0000,-1024.0000)

 

SetPosition is not what moves the water but it is needed to update where the water is after TranslateToRef to the "world space" ...

 

For what you're doing set a Xmarker down at the start point and one down at the end point. Then TranslateToRef like the script.

Then TranslateToRef back to the 1st XMarker. I know TranslateToRef is the fastest type of movement and I think that is what you're

looking for, for the pop back to XMarker #1 ...

 

.TranslateToRef(MarkerRef, 0.1) is very very fast. Faster then a blink of an eye. May even need to use 0.3 ...

 

 

I've tried to do both of these things.

 

Here's the problem I'm having now: the objects will translate, but they won't cycle properly since the function that I have to move them is also a translation function, and thus upon its completion triggers the "onTranslationComplete" event.

Scriptname ____________ZIU3 extends ObjectReference  


ObjectReference Property XSTART  Auto  ;This is an X marker that marks where the object is supposed to start
ObjectReference Property XEND  Auto  ;Another X marker where it winds up

function Move() ;moves the tunnel bits backwards behind the train
    StopTranslation()
    if Is3DLoaded()
        TranslateToRef(XEND, 1000.0)
    endif
EndFunction

function MoveToStart() ;moves the tunnel bits back to the starting position ahead of the train
    StopTranslation()
     if Is3DLoaded()
        TranslateToRef(XSTART, 1000000.0)
    endif
    registerForSingleUpdate(0.1)
EndFunction

Event OnCellLoad()
      MoveToMyEditorLocation() ;This is just a reset to keep tunnel pieces from going nuts and gaps from forming in the tunnel wall
    Move()
EndEvent

Event OnUpdate()
      Move()
EndEvent

Event OnTranslationComplete()
    MoveToStart()
EndEvent

Event OnTranslationFailed()
    MoveToStart()
EndEvent

The function "Move" is what makes the pieces of the tunnel move backward, behind the train.

 

The function "MoveToStart" is another translation function that moves them back to their original position at high speed, faster than the player can notice.

 

The issue though is that I can't use "OnTranslationComplete" to trigger "MoveToStart" since "MoveToStart" is also a translation function. This loop works once, after which the bits of the tunnel just jitter around in place, since "Move" and "MoveToStart" are triggering at the same time, and I don't know how to make one function work without triggering the other, unless there's a function that can make the script wait until the previous function is complete.

 

Then, if there is a function that can make the script wait until one function is complete, then I could have "Move" trigger, then use that function which halts the script until "Move" is done, which then, if all works correctly, make the script wait until "Move" is done, and then trigger "MoveToStart", and then use a "registerForSingleUpdate(0.1)" to use an "Event OnUpdate" loop to keep things going.

 

At present though, I don't know how to make this work, and all else has failed.

 

SetPosition and MoveTo don't work when "TranslateTo" or "TranslateToRef" is called; those two functions just stop working when translation functions are in use. I've tried just using "SetPostion" to move something to something else, and I've tried using "MoveTo" to get the individual pieces of the tunnel to move to an X Marker that I have at their respective start positions. NEITHER ONE WORKS after a translation.

 

 

Remove the Ontranslate fuctions ... place the hall x,y and z at the starting XMarker in the kit ... then translate it to the end XMarker, then SetPosition exactly where your end XMarker is x,y and z ... then use translate again to get back to the start XMarker but, this time set the move time super low so it just pops back in place. Then SetPosition again to the starting XMarker x,y and z ... Repeat ... This should be easy. As far as any extra pieces put a script on each one to stay (with their offsets) with the main hall. !st get just the hall working so you know that part is right then try to add the other parts.

 

You don't need to use Move or SetPosition to get it to pop back to the start XMarker ... you again use translate. (just with a faster move time) You can make it so it moves so fast it's basically just like a move statement.

Link to comment
Share on other sites

This kind of setup is all you need ... (with a faster wait like 0.5 or 1.0)

#1 SetPosition at start (starting XMarker)

#2 TranslateToRef (ending XMarker)

#3 Wait for it to complete the move

#4 Setposition at end (ending XMarker)

#5 Translate back to the start (using a super fast translate time)

#6 Now repeat from #1 until you are done moving the hall.

 

MarkerREF.SetPosition(2560.0000,2560.0000,-1024.0000)

WaterREF.TranslateToRef(MarkerREF, 10.0)
While(WaterREF.GetPositionZ()!=(-1024.0000))
Utility.Wait(2.0)
EndWhile
WaterREF.SetPosition(2560.0000,2560.0000,-1024.0000)
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...