Jump to content

TranslatetoRef() not triggering events


Recommended Posts

Can anyone think of why TranslateToRef() wouldn't trigger the events OnTranslationAlmostComplete(), OnTranslationComplete(), or OnTranslationFailed()?


I have a boat that moves from its dock to the first location in a chain of linked references of XMarkerHeading objects. They're properly linked together and I get a line from the origin to destination in the CK. But my boat only moves to the first XMarkerheading because I'm not getting any events after the first one.


My script catches OnTranslationAlmostComplete(), OnTranslationComplete(), or OnTranslationFailed() but none of them are triggered after the first TranslateToRef(). Can anyone think of why?

Link to comment
Share on other sites

I'm done the same in both my mods, so it definitely can work!

 

Just checking the obvious here, but Is the script running on the boat that's moving? Otherwise I'd be guessing the nif might not be the right kind of collision object, or didn't have all the right settings ticked. If you're happy about this, might be worth posting your script.

 

Cheers - dafydd99

Link to comment
Share on other sites

I didn't used the verb 'need', and I've no idea what 'your' script does or how it does it.

 

And just to be clear: I'm just providing alternatives and workarounds for the OP's issue with the data provided, so she/he can work on with.

Link to comment
Share on other sites

I'm done the same in both my mods, so it definitely can work!

 

Just checking the obvious here, but Is the script running on the boat that's moving? Otherwise I'd be guessing the nif might not be the right kind of collision object, or didn't have all the right settings ticked. If you're happy about this, might be worth posting your script.

 

Cheers - dafydd99

 

Thanks for the response, dafy. I had originally attached the script to the object containing the animated model of the boat. I had an even weirder problem with that in that the boat wouldn't move at all despite TranslateToRef() being called properly and no errors in the Papryus log. I'd been at a loss for months around that one, but decided to disable every mod except my own, and it magically fixed the problem and I finally got my ferry back.

 

It had been working fine for months, then "something happened" (I didn't know what, but I'd installed a bunch of mods) and my ferry wouldn't move at all. I wasn't sure if it was something I'd changed in my own mod (but I knew I hadn't changed the script), and only figured out a couple of days ago that another mod was causing the problem and I haven't yet had time to go through them all one by one to find out what was causing my boat not to move at all even though (according to the Papyrus log) it should have.

 

After disabling every other mod except the bare bones I need, such as SKSE and SkyUI for my MCM, my ferry started working perfectly again, toing and froing from Riften Dockside to my player home's pier and back at scheduled times.

 

But then I got the idea to put lanterns on the ferry after dusk until dawn. So, with everything finally working again, I changed the script to use PlaceAtMe()so my script can place either the day or night model of the ferry to do the traveling.

 

It's much more complicated than need be because I don't understand how to use REF_ATTACH_NODE in NIFs. What I want is to have one animated object (MoveableStatic) that has both a furled and set sail that I can switch with my script depending on whether the ship is in port or underway, and that spawns a couple of candle flames and a light object to light up the deck at night.

 

I see that the NIFs in Realistic Boat Bobbing use REF_ATTACH_NODE to attach barrels and whatnot on ship's decks so they move with the boats, but I can't see how to, for example, display the furled sail at port, the set sail when underway, or add candle flames to lanterns and a light to light up the deck at night. That's ultimately what I want to do with just one animated model, which would simplify everything a lot.

 

I've read that lights can be attached to animated objects, and if a light could be "turned on and off" I should be able to do the same with the sail (furled or set) and then just have one object controlled by a script that does everything. Then, I'd have the script attached to the MoveableStatic (the boat).

 

But the way it is now, I have a static ferry in port during the day, with its sail furled and no lanterns on, which I have to change to a different static (with lanterns) at night, and a day MoveableStatic (no lanterns) to do the ferrying during the day and a different model (with lanterns) at night.

 

To accommodate that, I'm using PlaceAtMe() to spawn the correct MoveableStatic depending on the time of day, so there's no script to attach anything to in the CK since the animated ships don't exist until the ferry starts moving.

 

I'm pretty sure my NIFs are fine. TranslateToRef() doesn't seem to care much what it moves, as long as the object isn't hidden with Disable(). I've had it move chairs that were statics. It just leaves the collision behind, so the chairs don't work in the new location. Then, if the player walks where the chairs were, they bump into the collision but it's invisible.

 

That's not happening. It's just a couple of flags to change with NIFSkope in bhkRigidBody:

 

Layer from SKYL_STATIC to SKYL_ANIMSTATIC

 

Then the same change in the duplicate Layer flag down in Rigid Body Info. I also change:

 

Motion System from MO_SYS_BOX_STABILIZED to MO_SYS_BOX_INERTIA

Quality Type from MO_QUAL_INVALID to MO_QUAL_FIXED

 

It's what Bethesda seems to change from Static to MoveableStatic objects.

 

The boat does move from the dock to first XMarkerHeading. I've verified through Debug.Trace() calls that it does reach the coordinates of the XMarkerHeading it's sent to by the first TranslateToRef().

 

My script just doesn't receive the OnTranslationAlmostComplete(), OnTranslationComplete() or OnTranslationFailed() events after that and I'm getting no errors in the Papyrus log so I'm at a complete loss.

Link to comment
Share on other sites

I didn't used the verb 'need', and I've no idea what 'your' script does or how it does it.

 

And just to be clear: I'm just providing alternatives and workarounds for the OP's issue with the data provided, so she/he can work on with.

 

I thought you'd done it again, maxarturo, and solved the problem. My script does use a "busy" state when the boat's moving after the Activator has been, well, activated.

 

The event I use for smooth sailing, OnTranslationAlmostComplete(), wasn't inside that "busy" state block, so of course it was being ignored when the script was in its busy state. Except that my script has always been like that (due to oversight; I'm not used to using events) and it was working fine for months... and I just changed it putting OnTranslationAlmostComplete(), along backup event handlers of OnTranslationComplete() and OnTranslationFailed() inside the "busy" state block, and everything is the same. :confused:

 

The boat still moves from the port to the first XMarkerHeading. It definitely arrives to where TranslateToRef() is supposed to move it to, but then neither OnTranslationAlmostComplete(), OnTranslationComplete() nor OnTranslationFailed() are triggered.

Link to comment
Share on other sites

Okay, a lot to unwind there - hopefully there's a few points I can give that might help you.

  • Firstly when developing a mod I'd def advise turning off all non-essential mods. It's always hard to tell what's modified what.
  • Yes it's ONLY the Object Reference that you're translating that would receive the onTranslate events.
  • If the Object Reference becomes 'unloaded' at some point, which can happen if the boat moves into an exterior cell more than one or two away from the player, then yes those events probably won't come through. If you can still see the boat, this won't be the problem.
  • The way to 'attach' references to each other is through the 'attach ref' tab on the creation kit References menu - this is described as 'not supported' but the developers have clearly tried to use this, as if you investigate the tiny island at the northeast of Solstheim (one with the spriggans and giant nirnroots in it) there is a tiny boat with chests/bags/etc 'attach ref'd to the animated boat quite successfully.
  • HOWEVER lights do not have this option! I have a light on my boat, but that is because I've actually used an object reference of the type 'light' as the boat (there are moving light examples in the 'black book' apocrypha dungeons - cf DLC2APOMovingLightNoShadow - seems that NINode must be named 'AttachLight'). This said, there is a 'wearable lantern' mod that seems to manage it somehow, but I'm not sure how!
  • if attached refs are disabled (which you might do to change the furled/unfurled sail) they will stop being 'attached'. There is a way around this - you can set name 'REF_ATTACH_NODE' style nodes (something like 'SAIL_ATTACH_NODE', and use https://www.creationkit.com/index.php?title=MoveToNode_-_ObjectReference just after re-enabling (maybe in the 'onload' event?). Alternative is to do some animation in the nif, but this might be tricky.
  • of course - you may not need to use 'ontranslationcomplete()' events at all? Just have a loop translating and then wait a period that matches the time you want to translate for (maybe check the 3d is still loaded) then do another translate?

Hope this helps - dafydd99

Link to comment
Share on other sites

Sirgallyhave


I didn't say to use a 'Busy' state, I said to "create your script using 'States', each 'State' for each sequence"


If you want to know what I mean send me a DM and I'll explain it with scripts examples.


PS: I haven't read your wall of text, but I'll read it later.

Link to comment
Share on other sites

Thanks much for the detailed post, dafy, it's much appreciated. Definitely it's good advice not to use other mods while developing. I find Mod Organzier 2 very handy for this as it allows us to maintain various profiles for different tasks.

It's confusing to me, because I'm using a property in the script (attached to the XMarkerActivator) that points to the animated object, say ObjectReference property anim_ref.

So I do this:

anim_ref.TranslateToRef(<XMarkerheading>, <speed>)

...Oh, now I get it. I'm moving the boat, so it moves properly, but the XMarkerActivator is what's set up to receive the OnTranslation*Complete() events, and it doesn't move, so the events aren't triggered.

Dang, I knew there was a reason I had the script attached to the MoveableStatic version of the boat. Thanks for saving my brain from melting down on that one.

Now I just don't know what to do about the sail and lanterns. I can go back to using one boring animated model for both day and night. I tried using Attach Ref on a light but it stayed dockside as the ferry sailed away. It sounds like you've accomplished a lot around this.

So you made your boat a light? :smile: I didn't think light objects had models but I just looked in the CK and they do indeed have room to add a model. Clever. How do you turn the light off during the day, or do you just leave it on?

I haven't looked at Wearable Lanterns but it probably just uses the feature torches use. If you look at base light objects from the Object Window, they have a checkbox at the top-right "This light can be carried" and I think that might be what Wearable Lanterns uses, just changing the torch model and moving its placement to a different node instead of the hand.

I think if we used that, players could pick up the light our boats use and put it in their inventory. :smile:

There's definitely a way to attach a light to an object using REF_ATTACH_NODE. Spells and other things use it to attach effects to things, and it's probably how arrows stick in things. I just can't find any documentation that I can understand. There's a bit here and there, but it's always brushed off as though it's simple and everyone knows how to use it. I might just not be searching the right keyword.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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