Jump to content

[LE] TranslateToRef() works but not MoveTo or SetPosition()


Recommended Posts

I've got a couple of chairs (of object type Furniture in the CK) I need to move from A to B within the same cell, only a few feet. It's to let players move a couple of chairs close to a fireplace if they want, and to move them back to the wall when they want them out of the way.

I had to edit the NIFs in NifSkope to change some flags so the collision wasn't left behind when the chairs moved and that's working fine. I move the chairs with a script attached to an Activator using TranslateToRef() to a couple of XMarkers closer to the fireplace, then back to a couple of other XMarkers near the wall as a toggle with the Activator. That part's working fine.

For reasons I'd rather not go into because it's a lot to explain, I need a disabled chair to move to wherever the visible ones end up and I can't get those chairs (disabled with Disable()) to move anywhere unless I Enable() them and use TranslateToRef().

Aren't we supposed to be able to move disabled objects with MoveTo(), like Disable() / MoveTo() / Enable() isn't that a thing used often? I thought it was better to move objects when they were disabled but the disabled chairs won't move with either MoveTo() or SetPosition().

Enable(), TranslateToRef(<Xmarker ref>, 10000), DisableNoWait() works fine to move them really fast, but it's obvious and looks terrible in the game. I want to move them while they're invisible.

Can anyone think of why they'll only move with TranslateToRef() only after Enable() and not when using MoveTo() or SetPosition() even after Enable()?

 

Edit: I should probably add that the two disabled chairs I'm trying to move with MoveTo() are referenced in the properties of another script, but they have no scripts attached to them. Could just the fact that they're referenced in another script's properties that be stopping them from moving but not with TranslateToRef()?

Link to comment
Share on other sites

I think that's the case, if I remember correctly since I haven't played with Papyrus and CK for quite some time. But I do recall encountering an issue like this.

In any case, if this is the case then try something like this:

- Link ref the activator to the translated object, and then in your script do something like this, this is just an example that I'm writting from the top of my head while hunging out on a beach surrounded by mosquitos:


ObjectReference ObjRef = ParentObj.GetLinkedRef()
ObjRef.TranslateToRef()
;;;; Here you either add a 'wait' function
;;;; Or
Event OnTranslationComplete()
ObjRef = NONE ;;; Object is no longer persistence on the activator's script
EndEvent

;;;; Now you can use the 'MoveTo()' function

Link to comment
Share on other sites

I think that's the case, if I remember correctly since I haven't played with Papyrus and CK for quite some time. But I do recall encountering an issue like this.

In any case, if this is the case then try something like this:

- Link ref the activator to the translated object, and then in your script do something like this, this is just an example that I'm writting from the top of my head while hunging out on a beach surrounded by mosquitos:

 

ObjectReference ObjRef = ParentObj.GetLinkedRef()
ObjRef.TranslateToRef()
;;;; Here you either add a 'wait' function
;;;; Or
Event OnTranslationComplete()
ObjRef = NONE  ;;; Object is no longer persistence on the activator's script
EndEvent
 
;;;; Now you can use the 'MoveTo()' function

Thanks for the response. That's what I was thinking too, that I'll have to set the references in the other script to 'none' temporarily while I move the chairs, then point the refs back at the objects once they're moved. If it works I'll post back here to confirm.

 

Edit: That was the problem. Apparently if an object is referenced in a script property, it can't be moved with MoveTo() or SetPosition(), but TranslateToRef() will move it even while referenced by a script property, as long as the object is enabled with Enable() before calling TranslateToRef().

 

Just to clarify, you obviously have to reference whatever you're trying to move in a script property or you can't refer to the object. The issue is whether another script is referencing the same object. If a separate script has the object you're trying to move in an ObjectReference property (probably any property), you'll have to set the reference in the other script to 'none' before MoveTo() will work in the first script.

Link to comment
Share on other sites

You didn't specify that there is another script trying to manipulate the same Obj, your post 'insinuates' that the same script is trying to 'Translate' and 'MoveTo' the same object.

* Which I do remember encountering an issue of some sort in the past with one 'translate' function and 'moveto', or was 'SetAngle'...???


But yes, when 2 scripts, each one living in different references try to manipulate the same object, they need to set the function called on the manipulated object to = NONE


There is only a few Papyrus functions that don't require this, but don't ask me which ones because I can't remember right now.

Edited by maxarturo
Link to comment
Share on other sites

You didn't specify that there is another script trying to manipulate the same Obj

Edit: I should probably add that the two disabled chairs I'm trying to move with MoveTo() are referenced in the properties of another script[...]

It didn't occur to me initially but I'd added the edit before you responded.

 

But yes, when 2 scripts, each one living in different references try to manipulate the same object, they need to set the function called on the manipulated object to = NONE

 

There is only a few Papyrus functions that don't require this, but don't ask me which ones because I can't remember right now.

As I mentioned, TranslateToRef() will move objects even if they're referenced in other scripts but the object must be enabled first.

 

Your response was correct, thanks for taking the time.

 

Link to comment
Share on other sites

  • 2 weeks later...
  • Recently Browsing   0 members

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