Jump to content

MoveTo script headache.


PCDug

Recommended Posts

TLDR;When using the move to function the object is moved to the right marker but with the wrong rotation (the rotation remains the same as the one in the starting point)

 

 

 

Hi,I'm having a bit of trouble with the MoveTo function not doing what it's supposed to do in my script.

 

Game.FadeOutGame(false, true, 4.0, 3.0)
CurrentPos.Disable()
MBFuelCOuntGlobal.SetValue(MBCurrentFuel-MBRequiredFuel)
MBCoolantCOuntGlobal.SetValue(MBCurrentCoolant-MBRequiredCoolant)
GameHour.SetValue(MBHour+((Distance/7140000)*30))
MBDriveSound.Play(Game.GetPlayer())
DestPos.Enable()
MBDoor.MoveTo(mDestPos, abMatchRotation = true)
MBDoorMarker.MoveTo(mDestPos,70.0 * Math.Sin(mDestPos.GetAngleZ()), 70.0 * Math.Cos(mDestPos.GetAngleZ()), - 80.0,abMatchRotation = true)
CurrentPos=DestPos
The last section of this script is supposed to move a door and an xmarker around the world (the destination is always an xmarkerHeading).The moveTo function works ok for the MBDoorMarker property (the xmarker is moved to the destination with a slight translation and faces the right way.
The MBDoor property however gets moved to the right spot but retains it's original rotation (it does not allign with the xmarkerheading rotation).
Why is the rotation change working for the moved xmarker but not for the moved door?
Edited by PCDug
Link to comment
Share on other sites

Firstly MoveTo is latent, and nothing else is going to happen until the move is finished. There is possibly a queue issue going on there between the two moves.

 

You can try adding "Utility.wait(0.2)" after the first move.

Thank I'll try that.What boggles me is that move object should match the markerheading rotation by default,I mean,that worked in my other mod.

 

ElseIf aiButton == 1
DriveSound.Play(Game.GetPlayer())
Game.FastTravel(mabf)
Car.MoveTo(abf)
VanFuelUnit.RemoveItem(FuelUnit, 1, True)
Doing this moved a static car to the xmarkerheading (near abernathy farm in this case).It did the same for other 32 location and the car would always be in the correct orientation.
Link to comment
Share on other sites

I am thinking the "pointer" of the XmarkerHeading isn't used as a point of reference for rotation at all.

Recent versions of this mod of mine http://www.nexusmods.com/fallout4/mods/15994/? use the moveto function and xmarkerheading to do what it does.It worked fine for that mod.

The sole purpose of xmarker headings is to be directional.The pointer is just a visual rappresentation.They are just static items after all.They don't do anything special.

I use them just to be cohesive with the rest of the game.

If I use moveto on a reference and point it to a marker rotated say (0,90,0) according to the wiki by default the reference moved to it should match that 3d orientation.But for some reason these references get moved but not rotated.I'll have to check the whole script again for some dumb mistake i guess.Here it is just for funsies.(NOT completed)

 

Scriptname PCDugMBTravelScript extends ObjectReference

 

Quest Property MBPositionQuest Auto

Message Property MBTravelMessage01 Auto

Message Property MBTravelMessage02 Auto

Message Property MBTravelMessage03 Auto

Message Property MBNoFuelMessage Auto

Message Property MBNoCoolantMessage Auto

Sound Property MBDriveSound Auto

GlobalVariable Property GameHour Auto

GlobalVariable Property MBFuelCOuntGlobal Auto

GlobalVariable Property MBCoolantCountGlobal Auto

float Property Distance Auto

float Property MBHour Auto

float Property MBRequiredFuel Auto

float Property MBRequiredCoolant Auto

float Property MBCurrentFuel Auto

float Property MBCurrentCoolant Auto

Quest Property MBFuelQuest Auto

Quest Property MBCoolantQuest Auto

 

ObjectReference Property MBDoor Auto

ObjectReference Property MBDoorMarker Auto

 

ObjectReference Property CurrentPos Auto

ObjectReference Property DestPos Auto

ObjectReference Property mDestPos Auto

 

ObjectReference Property abf Auto <-------These are initially disabled references of a vehicle placed around the world.

ObjectReference Property acg Auto

ObjectReference Property air Auto

ObjectReference Property bkh Auto

ObjectReference Property cst Auto

ObjectReference Property csc Auto

ObjectReference Property cps Auto

ObjectReference Property ctc Auto

ObjectReference Property cvt Auto

ObjectReference Property cpm Auto

ObjectReference Property dmc Auto

ObjectReference Property egs Auto

ObjectReference Property egt Auto

ObjectReference Property fnf Auto

ObjectReference Property gdn Auto

ObjectReference Property ggn Auto

ObjectReference Property gtn Auto

ObjectReference Property hma Auto

ObjectReference Property jmp Auto

ObjectReference Property kpl Auto

ObjectReference Property mwc Auto

ObjectReference Property nhb Auto

ObjectReference Property obs Auto

ObjectReference Property onc Auto

ObjectReference Property opz Auto

ObjectReference Property rrk Auto

ObjectReference Property sct Auto

ObjectReference Property slg Auto

ObjectReference Property smp Auto

ObjectReference Property spc Auto

ObjectReference Property srl Auto

ObjectReference Property stc Auto

ObjectReference Property tfb Auto

ObjectReference Property tpb Auto

ObjectReference Property vlt Auto

ObjectReference Property wwh Auto

ObjectReference Property ist Auto

 

ObjectReference Property mabf Auto <-------These are xmarker headings placed where i want the door to be moved

ObjectReference Property macg Auto

ObjectReference Property mair Auto

ObjectReference Property mbkh Auto

ObjectReference Property mcst Auto

ObjectReference Property mcsc Auto

ObjectReference Property mcps Auto

ObjectReference Property mctc Auto

ObjectReference Property mcvt Auto

ObjectReference Property mcpm Auto

ObjectReference Property mdmc Auto

ObjectReference Property megs Auto

ObjectReference Property megt Auto

ObjectReference Property mfnf Auto

ObjectReference Property mgdn Auto

ObjectReference Property mggn Auto

ObjectReference Property mgtn Auto

ObjectReference Property mhma Auto

ObjectReference Property mjmp Auto

ObjectReference Property mkpl Auto

ObjectReference Property mmwc Auto

ObjectReference Property mnhb Auto

ObjectReference Property mobs Auto

ObjectReference Property monc Auto

ObjectReference Property mopz Auto

ObjectReference Property mrrk Auto

ObjectReference Property msct Auto

ObjectReference Property mslg Auto

ObjectReference Property msmp Auto

ObjectReference Property mspc Auto

ObjectReference Property msrl Auto

ObjectReference Property mstc Auto

ObjectReference Property mtfb Auto

ObjectReference Property mtpb Auto

ObjectReference Property mvlt Auto

ObjectReference Property mwwh Auto

ObjectReference Property mist Auto

 

 

 

 

 

 

 

Event OnActivate(ObjectReference akActionRef)

MBFuelQuest.Start()

MBCoolantQuest.Start()

MBPositionQuest.Start()

MBPositionQuest.Setstage(100)

Menu()

EndEvent

Function Menu(Int aiButton = 0)

aiButton = MBTravelMessage01.show()

 

If aiButton == 0 <-------to choose the destination

DestPos=CurrentPos

ElseIf aiButton == 1

DestPos=abf

mDestPos=mabf

ElseIf aiButton == 2

DestPos=acg

DestPos=acg

ElseIf aiButton == 3

DestPos=air

mDestPos=mair

ElseIf aiButton == 4

DestPos=bkh

ElseIf aiButton == 5

DestPos=cps

ElseIf aiButton == 6

DestPos=cst

mDestPos=mcst

ElseIf aiButton == 7

DestPos=ist

ElseIf aiButton == 8

DestPos=csc

ElseIf aiButton == 9

DestPos=ctc

ElseIf aiButton == 10

DestPos=cvt

ElseIf aiButton == 11

DestPos=cpm

ElseIf aiButton == 12

DestPos=dmc

ElseIf aiButton == 13

DestPos=egs

ElseIf aiButton == 14

DestPos=egt

ElseIf aiButton == 15

DestPos=fnf

ElseIf aiButton == 16

DestPos=gdn

ElseIf aiButton == 17

DestPos=ggn

ElseIf aiButton == 18

DestPos=gtn

ElseIf aiButton == 19

aiButton = MBTravelMessage02.show()

 

 

If aiButton == 0

DestPos=CurrentPos

ElseIf aiButton == 1

DestPos=hma

ElseIf aiButton == 2

DestPos=jmp

ElseIf aiButton == 3

DestPos=kpl

ElseIf aiButton == 4

DestPos=mwc

ElseIf aiButton == 5

DestPos=nhb

ElseIf aiButton == 6

DestPos=obs

ElseIf aiButton == 7

DestPos=onc

ElseIf aiButton == 8

DestPos=opz

ElseIf aiButton == 9

DestPos=rrk

ElseIf aiButton == 10

DestPos=sct

ElseIf aiButton == 11

DestPos=slg

ElseIf aiButton == 12

DestPos=smp

ElseIf aiButton == 13

DestPos=spc

ElseIf aiButton == 14

DestPos=srl

ElseIf aiButton == 15

DestPos=stc

ElseIf aiButton == 16

DestPos=tfb

ElseIf aiButton == 17

DestPos=tpb

ElseIf aiButton == 18

DestPos=vlt

ElseIf aiButton == 19

aiButton = MBTravelMessage03.show()

If aiButton == 0

DestPos=CurrentPos

ElseIf aiButton == 1

DestPos=wwh

 

 

EndIf

EndIf

EndIf

 

If DestPos != CurrentPos

 

MBHour = GameHour.GetValue()

Distance=(CurrentPos.Getdistance(DestPos))

MBCurrentFuel=MBFuelCOuntGlobal.GetValue()

MBCurrentCoolant=MBCoolantCountGlobal.GetValue()

MBRequiredFuel=(Distance/14280)

MBRequiredCoolant=(Distance/7140)

 

If MBCurrentFuel >= MBRequiredFuel

If MBCurrentCoolant >= MBRequiredCoolant

 

Game.FadeOutGame(false, true, 4.0, 3.0)

CurrentPos.Disable() <-----disables vehicle reference at current position

MBFuelCOuntGlobal.SetValue(MBCurrentFuel-MBRequiredFuel)

MBCoolantCOuntGlobal.SetValue(MBCurrentCoolant-MBRequiredCoolant)

GameHour.SetValue(MBHour+((Distance/7140000)*30))

MBDriveSound.Play(Game.GetPlayer())

DestPos.Enable() <----enables the vehicle reference at the destination

 

MBDoor.MoveTo(mDestPos, abMatchRotation = true) <-----moves door to the destination marker heading (DOES NOT ROTATE THE THING FOR SOME RESON)

 

MBDoorMarker.MoveTo(mDestPos,70.0 * Math.Sin(mDestPos.GetAngleZ()), 70.0 * Math.Cos(mDestPos.GetAngleZ()), - 80.0,abMatchRotation = true) <-------moves another marker heading in front of the door (AGAIN,DOES NOT ROTATE IT)

 

 

 

CurrentPos=DestPos

 

Else

aiButton = MBNoCoolantMessage.show()

If aiButton == 0

 

Else

aiButton = MBNoFuelMessage.show()

If aiButton == 0

 

EndIf

EndIf

EndIf

EndIf

EndIf

 

MBFuelQuest.Stop()

MBCoolantQuest.Stop()

 

EndFunction

 

Edited by PCDug
Link to comment
Share on other sites

Try using a different syntax:

 

MBDoor.MoveTo(mDestPos,0,0,0,true)

 

Otherwise, have you tried using MoveToNode, I can confirm that matching rotation works for this. It could save you from having to use all those messy markers as well.

Link to comment
Share on other sites

Try using a different syntax:

 

MBDoor.MoveTo(mDestPos,0,0,0,true)

 

Otherwise, have you tried using MoveToNode, I can confirm that matching rotation works for this. It could save you from having to use all those messy markers as well.

I already tried the full syntax (destination x,y,z offset,abmatchrotation=)id does not work

I'll look into the movetonode,I could really use getting rid of 30+ properties.

 

EDIT-If someone is wondering why I don't use moveTo for the vehicle itself the answer is that MoveTo does not work on static collections.

Edited by PCDug
Link to comment
Share on other sites

If push come to shove, take a somewhat longer/complicated route(well you seem to know your way around math so might be easier) can use http://www.creationkit.com/fallout4/index.php?title=SetAngle_-_ObjectReference to turn the thing around yourself.

Now that I think about it I should be able to do something like objecttorotate.setangle(TargetRef.GetangleX(),TargetRef.GetangleY(),TargetRef.GetAngleZ())

I just need to check if that syntax is a thing or not.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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