Talk:MoveTo
Restrictions?[edit source]
Anyone actually tried using MoveToMarker instead of MoveTo when dealing with "transportation" to an XMarker? Seems to work in-game as its used by Bethesda scripts as well. ReinhartMenken 23:44, 18 April 2007 (EST)
Does anyone know of any restrictions on this command? I and another person can't get MoveTo to move objects, but it seems that activators move sucessfully using the exact same code. Update: An activator with a model set doesn't seem to move with this command. (I used skull01.nif) Mrflippy 00:42, 8 April 2006 (EDT)
Hmm... MoveTo doesn't seem to like XMarkers (reference.MoveTo player doesn't work). Any suggestions?Talkie Toaster 12:26, 20 April 2006 (EDT)
What does this function work on? I think testing needs to be done on this. The article says it works for Actors, and implies that it doesn't work for some (or all) non-actors. Flippy is saying that it works for Activators with no mesh, but not for non-activators or activators with a mesh. I personally would really like to use this function for a neat effect I have in mind, but it won't work if I can't move meshes with this... I may do some testing later, if I get the chance, but testing definitely needs to be done by someone, regardless. --DragoonWraith 16:57, 23 May 2006 (EDT)
- from my testing it seems to work fine on misc items. I created a test Mark/Recall spell, with the mark spell simply calling markObj.MoveTo player. the misc item in this case was a paintbrush. seemed to work repeatedly. :shrug: Scruggs 22:54, 26 May 2006 (EDT)
- Well, that's encouraging. Thank you! --DragoonWraith 22:56, 26 May 2006 (EDT)
- It works fine on any item, even those created with placeatme, but only as long as they're in a loaded cell. That's not really a moveto problem, it's a general problem with non-persistent references. Moveto on a carriable item once it is in a container/inventory is a very reliable way to crash the game, no matter if the reference is persistent or not.--JOG 03:28, 27 May 2006 (EDT)
- Understood. In my case the object was previously placed in the editor, persistent, and disabled...so that ensures that moveTo will always work, correct? Scruggs 11:49, 27 May 2006 (EDT)
- Say I have an object set to constantly MoveTo player 0 0 0, will that follow him through a loaddoor? If this script is in a Quest script (objectID.MoveTo player 0 0 0), and the player goes through a loaddoor, will that crash or will that work? If I have a reference variable instead of the actual ID, will that change anything? If that reference var references an object created through PlaceAtMe, does that change anything? If it works as it all, must it be a persistant reference in order to do so? --DragoonWraith 13:44, 27 May 2006 (EDT)
- Yes, this should work. MoveTo even moves the object into diffrent cells if necessary. It shouldn't crash the game when you take care that the used reference didn't get unloaded. you should therefore use persistant references. And you don't even need the "0 0 0" thing, just using "MoveTo Player" should do the job. --JustTim 16:50, 27 May 2006 (EDT)
- Excellent, thank you. --DragoonWraith 17:13, 27 May 2006 (EDT)
I'm having no luck with activators. "Unexpected behavior" certainly sums it up. Activators don't seem to respond to MoveTo in the console, regardless of persistence. In a script, they seem to respond once, with subsequent calls having no effect. Strangely, calling activator.MoveTo from a different cell correctly moves it the first time, but after leaving and immediately re-entering the cell, the activator has vanished, and attempts to reference it via the console to check getDistance report an invalid reference! Scruggs 00:02, 29 May 2006 (EDT)
- Yes, the behavior of this function on non-actors is a little weird. The best method seems to be a combination of MoveTo and SetPos. MoveTo ONLY works when the object moves into another cell and SetPos does NOT work if the object moves into another cell. Just call both functions and it should work. But you should call MoveTo last, since it might abort the script (like a "return").
- But there is a downside: The object loses its special behavior when moved by a setpos function. You can't activate it anymore and collusion doesn't work anymore. --JustTim 05:06, 29 May 2006 (EDT)
- A note on that problem--I had noticed that there seems to be a difference between a typical activator .nif and a typical static .nif, as activators seem to move fine with setPos (with the exception of occasionally disappearing when going from cell to cell) but stop working when you change the .nif file to one from a static.
- I messed around with the .nif nodes a bit, and I found I could get a nif file from an underwater rock (i.e. a static) to function properly by replacing its bhkRigidBody node with a bhkRigidBodyT node stolen directly off of an aylied press block, and keeping other parts of the data tree intact. I am, however, still using the modified nif file on an activator object, whether the rock can now be moved properly as a static is unknown.
- Also note: since setPos essentially teleports the object, the object mentioned above doesn't interact properly with other objects while moving, though interaction is certainly there. Objects placed on top will tend to fall off, objects placed in its path may get stuck inside, etc. Expect headaches if you're trying to actually simulate a moving solid object. --ulto_leif 16:51, 30 June 2008
After messing around with this function a bit, I'm finding that when called on an activator, it seems to update the activator's position without remembering to update the world art at the same time. Sometimes the object will remain in the same place after a MoveTo, but getPos returns its coordinates as having changed to the new position. So, after calling moveTo, if you call 'setPos x (getPos x)', it seems to force the world art to update. Haven't noticed any issues with collision or activation when using this workaround. Scruggs 20:11, 26 June 2006 (EDT)
So basically, you can keep something always several paces in front or behind the player by executing this command in GameMode followed by SetPos? Sounds a whole lot easier than calculating the heading of the player using trig. --Omzy 22:46, 26 June 2006 (EDT)
- Not quite. MoveTo isn't relational in the way PlaceAtMe is. The offset values allow you to offset the position on each axis, but to specify "in front" or "behind" you would still need to take the player's facing angle into account. Scruggs 00:15, 27 June 2006 (EDT)
Bummer, thought it came with directional flags like placeatme. Shows how much use its been to me. --Omzy 00:34, 27 June 2006 (EDT)
Are there any functions similar to GetPos in Morrowind? That could be useful for finding the position, then using the GetAngle (I think) on the player to determine where to put the object. So if angle == 180, then position the object -100 of the player, using the GetPos as a reference (ex player at 2048 -> angle == 180 Move to (X - 128),(Y -0 )) or something like that. The Imperial Dragon 00:44, 27 June 2006 (EDT)
TheImperialDragon, Check out the scripts on the spellpack in your talk page. Most of them use trig to animate objects to move around actors. The discharge spell is a good example. --Omzy 01:34, 27 June 2006 (EDT)
- Actually there is a GetPos function that works exactly like the one in Morrowind, and have a look at this thread in the forum, it resulted in a spell that teleports you right behind a victim:
- And here's the esp with the spell: http://home.tiscali.de/jo.ge1/shadowstep.esp
- --JOG 10:08, 27 June 2006 (EDT)
Is it confirmed that the script added to the article actually works as intended? My concerns are: 1) Doing enable/disable on an object in the same frame can cause a crash; 2) Many static objects just wont teleport (in my exp); 3) I'm not sure this makes any difference to objects that seem to leave there collison meshes behind. GuidoBot 18:37, 29 November 2006 (EST)
- :shrug: It's confirmed as far as I use it with several types of objects in my mods, including statics. I've never seen a crash with enable and disable called in the same frame. The purpose of the final SetPos is to update the collision and world art when the object is moved from a different cell. Scruggs 19:02, 29 November 2006 (EST)
- Does this mean you can move/teleport buildings and containers? Does it make a difference if these are persistant or remote from the player's current location? I dont mean to push here but I'd given up trying to use MoveTo on certain types of objects but I would be willing to try again if you think this code solves the issues? On the other hand, I've not had many of the problems using MoveTo with actors and other stuff that others have reported on the forums. As far as crashes go with enable/disable, I think it depends on the state of the object when certain commands are done. On several occassions I've had to enable one frame, do something, then disable on the next frame to avoid crashes. GuidoBot 19:46, 29 November 2006 (EST)
- Well, if you're moving something from a remote cell, it has to be a persistent reference of course. That goes for calling any function on a remote object, not moveTo specifically. Scruggs 20:07, 29 November 2006 (EST)
- Doh! Sorry to confuse things. Come to think of it, I've never tried to move a container or house that was already in the player cell, only stuff I've created or persistant objects moved from remote cells. GuidoBot 20:52, 29 November 2006 (EST)
- Well, if you're moving something from a remote cell, it has to be a persistent reference of course. That goes for calling any function on a remote object, not moveTo specifically. Scruggs 20:07, 29 November 2006 (EST)
Moving Platforms[edit source]
I'm trying to make it so I can move some square object to do these scenes:
- PC stands on the platform, quest updates and removes player controls. The platform moves up to the top, dialogue happens and the platform starts moving freely (Rotating, moving around the room)
- PC is on a platform above lava with controls on and has to shoot another NPC on another moving platform across the lava.
Is this command even able to do those two things? If it can can I control how fast they move? Also is there a way I could make them move to an X marker instead of just to a coordinate? And finally does moveto act as a teleport or literally moving the object to the area?--A Colossal Problem 13:07, 18 August 2008 (EDT)
moveTo'ed object with a Unique inventory[edit source]
I am using a placeAtMe function for a script, which on death of a certain NPC, removes the corpse and places a skeleton instead. The notes under the placeAtMe function advise me to use the moveTo whenever possible and so I try to. I use a persistent refer. and moveTo the corpse's position - everything work's just fine except ....
After I move the skeleton, I removeAllItems from the corpse to the skele. But since I only moving the same reference all the time, all of the skeletons moved have a common inventory.
How to get an unique inventory on moving a persistent ref. using moveTo ( like in placeAtMe ) ? Is it even possible ? -- shademe 05:42, 13 September 2008 (EDT)
- You would need a separate skeleton persistent ref for each corpse that has a different inventory.
- PlaceAtMe will not cause problems if you are using it some finite number of times; the real risk is if you were to use it in such a way that it appears an arbitrary number of times (as in, every time the player does xyz). For your purposes, using PlaceAtMe seems safe.
- Dragoon Wraith TALK 09:37, 13 September 2008 (EDT)
- oh.. fine ! Thanks :) But a separate persistent skele ref. is not practically possible. so placeatme should work fine, I guess ! -- shademe 00:54, 15 September 2008 (EDT)
Player.MoveTo in OnEquip/OnAdd blocks[edit source]
Moving the player with MoveTo within an OnEquip or OnAdd block causes an infinite loop: the Player is MoveTo'd every frame thereafter.
It seems that instead of "acting as a return" the MoveTo function crashes the script AFTER moving the player or, somehow, prevents the script from complete successfully. The game engine seems to notice that the block did not complete successfully and tries to run it again the next frame. The Player will be moved again. The script will crash again, etc, etc. Final result: the player is moved to the same spot every frame - cannot move from there. This crash effect may be related to the fact that the scripted object is moved with the player as it does not occur in an OnDrop block or if the object is added to an NPC/container (in both cases, the object stays behind and is not moved with the player)
Workarounds: (1) add controls to prevent the MoveTo function from running two frames in a row or (2) Move the Moveto function to another block or another script.
Obs: PositionCell does not have this problem. QQuix 11:36, 22 February 2009 (EST)
Player.MoveTo Player[edit source]
Doesn't quite work as expected if trying to move yourself relative to yourself. The game fades out and fades back in with you at your new x,y coordinates and at ground-level regardless of the Z you set, and time seems to have advanced by a minute or more. You can expect the weather to have changed by the time you appear in your new position, even if you moved only an inch. Basically, it's as if you walked really slowly to the new x,y coordinates, yet as if there were no obstacles in your path. SetPos would be a better choice for levitation/flight scripts. More testing is needed to figure out the exact effects of using yourself as the point of reference for your own movement though. ---8asrun6aer 2011-12-21
- That's... really interesting. I don't know that anyone's tried that before.
- But yeah, SetPos is the usual method for doing this sort of thing.
- Dragoon Wraith TALK 10:05, 22 December 2011 (EST)
- I'm guessing using the function like this initiates 'fast travel'. It's just funny that it's not very fast when you're only moving a few feet over.
- 8asrun6aer 00:51, 23 December 2011 (EST);
Cannot Get This To Work With Spells or Items[edit source]
I am having major problems with this fuction, after days of fighting with it im extreemly fustrated. I am trying to make an item that teleports the player to a marker, I use it with Begin OnActivate it doesnt work, I tried it with a spell Begin ScriptEffectStart it doesnt work there either, I added message boxes just to make sure and they do not appear either, the whole script doesnt seem to work with items or spells so how do I use it? I have also tried MoveToMarker with all of the above, nothing works. I know I am doing my scripts right cause when I use message boxes alone they show up, but they dont show up when I use moveto. Mightylink 5:00, 17 May 2009 (EST)
- Make sure you take note #2 into account: the script will return after player.MoveTo.
- --Qazaaq 18:01, 18 May 2009 (EDT)
- I found the problem, apperently the script wont compile if you are moving to an already existing marker, I dropped in my own xmarker and it worked perfect now.
- --Mightylink 12:44, 21 May 2009 (EDT)