dafydd99 Posted July 13, 2023 Share Posted July 13, 2023 So, just to clarifty, if you're doing this... anim_ref.TranslateToRef(<XMarkerheading>, <speed>) then the anim_ref reference, the one that's actually being translated, would be the one to receive the translation events - the xmarkerheading is just the location it's translating to. If you were using 'translateto(x, y, z etc)' anim_ref would also be receiving the events. Yes, in my case, I do have the boat moving around a dank dungeon with no changing light situations, the lantern at the bow of the boat. But I also have it in daylight too. If I wanted to turn it off in daylight I'd probably just switch it to a different nif, as I'm not sure there's a way to control how bright a light is. There are a number of different form types which allow you to add a light source - my mods include several kinds of 'light arrows'. A 'projectile' will let you attach a light in the ck. I don't know if you could look into how a spell effect might stay active and 'attached' on your boat - perhaps that could be a light source? I think the 'this light can be carried' just lets you hold it as if it were a torch - ie out in front of the player with the hand in a fist shape. Yes certainly there's are mechanisms to attach as you say, but I believe they're engine level and we have no access to them. Fallout 4 has 'placeatnode' which we don't in skyrim. We can 'movetonode' but that doesn't attach. Happy to be proved wrong though as it would make my life easier! Cheers - dafydd99 Link to comment Share on other sites More sharing options...
Sirgallyhave Posted July 13, 2023 Author Share Posted July 13, 2023 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?This is how I did it originally, using Utility.Wait() and just calling TranslateToRef() once I'd guesstimated the boat had reached the next XMarkerHeading. I had to space the XMarkerHeadings out using a Dwemer triple-length pipe I used as a ruler/spacer. :smile: It was too much of a pain, so I switched to using OnTranslationComplete(), which made my boat pause for a bit at each XMarkerHeading. I finally used OnTranslationAlmostComplete() and got smooth sailing. Now I can also move my XMarkerHeadings around at will without having to worry about timing or their spacing. Link to comment Share on other sites More sharing options...
dafydd99 Posted July 13, 2023 Share Posted July 13, 2023 Fair enough. You can get a precise value for the journey time by doing something like this... float distance=Math.Sqrt((startX-destX)*(startX-destX)+(startY-destY)*(startY-destY)+(startZ-destZ)*(startZ-destZ)) float toWait=(distance/mySpeed) toMove.translateToRef(destination, mySpeed, 0) utility.wait(toWait) or even simpler using getDistance() Link to comment Share on other sites More sharing options...
Sirgallyhave Posted July 13, 2023 Author Share Posted July 13, 2023 So, just to clarifty, if you're doing this... anim_ref.TranslateToRef(<XMarkerheading>, <speed>) then the anim_ref reference, the one that's actually being translated, would be the one to receive the translation events - the xmarkerheading is just the location it's translating to. If you were using 'translateto(x, y, z etc)' anim_ref would also be receiving the events.Yes, I think the confusion is between XMarkerActivator and XMarkerHeading, which I just confused myself in a post above. If you think of the object my script is attached to as, say, a DweLever01 object it may be clearer what's happening. The lever has the property 'anim_ref' attached to it, and the lever is what's making the anim_ref.TranslateToRef(...) call. So, the boat moves because it's getting the proper command. But the lever (I'm using an XMarkerActivator, but) is what gets the OnTranslationAlmostComplete() event, right? The boat has no script attached to it, so I don't think it can catch any events. (I'm not just posting this for our benefit but for anyone else who runs across this in the future, I want it to be as clear as possible.) Yes, in my case, I do have the boat moving around a dank dungeon with no changing light situations, the lantern at the bow of the boat. But I also have it in daylight too. If I wanted to turn it off in daylight I'd probably just switch it to a different nif, as I'm not sure there's a way to control how bright a light is.That's what I was thinking of doing too. I have two different NIFs, the day and night ship model, one with lanterns, one without. But, hmm. I'm trying to think whether I could attach a copy of the same script (to carry out the TranslateToRef()) to both of those objects and then have my "lever" (activator to make the boat move) just activate the script attached to the right object depending on the time of day. That might work, but I still need to get a light moving with the night model of the boat. If I make the boat itself a Light instead of a MoveableStatic, do you think I can do that? Link to comment Share on other sites More sharing options...
Sirgallyhave Posted July 13, 2023 Author Share Posted July 13, 2023 Fair enough. You can get a precise value for the journey time by doing something like this... float distance=Math.Sqrt((startX-destX)*(startX-destX)+(startY-destY)*(startY-destY)+(startZ-destZ)*(startZ-destZ)) float toWait=(distance/mySpeed) toMove.translateToRef(destination, mySpeed, 0) utility.wait(toWait) or even simpler using getDistance() Very interesting, I would never have thought of doing that or using GetDistance(), which seems even easier. But I still think just letting OnTranslation*Complete() is a more reliable way to do it, assuming the object being moved has the script on it that catches the event. :smile: I will keep your proposition under my hat though because I'm sure it'll be useful for other things and I'm terrible at math, so thanks for posting that. The more tools in the toolbox, the better. Link to comment Share on other sites More sharing options...
dafydd99 Posted July 13, 2023 Share Posted July 13, 2023 So let's say you have three object references. An activator, the boat, and the xmarker. The activator may have the script that tells the boat to move to the xmarker - but it would be the boat (and specifically the scripts running on it) that would receive the events. Think of it this way - if the script moved five boats, how would it know which one had completed its translation? Link to comment Share on other sites More sharing options...
Sirgallyhave Posted July 13, 2023 Author Share Posted July 13, 2023 So let's say you have three object references. An activator, the boat, and the xmarker. The activator may have the script that tells the boat to move to the xmarker - but it would be the boat (and specifically the scripts running on it) that would receive the events. Think of it this way - if the script moved five boats, how would it know which one had completed its translation? Exactly. Only the object with the script containing the OnTranslation*Complete() event handler will receive that event. I'm using boats that pop out of thin air with PlaceAtMe(), so they have no scripts attached, so can't catch any events. My Activator is what the events would be sent to, and it doesn't move so it'd never trigger OnTranslation*Complete(). That issue is well and I hope thoroughly solved so anyone reading understands what was happening. Maybe I should start a new topic for the sail, candle flames and light because the original issue I raised in this topic is solved. Thanks very much, dafy. Link to comment Share on other sites More sharing options...
dafydd99 Posted July 13, 2023 Share Posted July 13, 2023 No worries! Though just to add, actually, yes you can have a script on a reference you make by making a new base object for it. Just duplicate it and add a script. You can then get the reference returned from 'placeAtMe'. Link to comment Share on other sites More sharing options...
Sirgallyhave Posted July 13, 2023 Author Share Posted July 13, 2023 No worries! Though just to be add, actually, yes you can have a script on a reference you make by making a new base object for it. Just duplicate it and add a script. You can then get the reference returned from 'placeAtMe'. What a great tip, thanks! I should have known this, as I attach scripts to base objects fairly often and of course they're also attached to the references we drop into the Render window in the CK. But I didn't know the same would work with PlaceAtMe() and it makes sense. That's great to know. Link to comment Share on other sites More sharing options...
Recommended Posts