Jump to content

[LE] Help with MoveTo()


Recommended Posts

Hi all,

 

I try to spawn multiple bedroll in a tent at precise position using MoveTo().
I've got everything running, except for that precise placement on each of the bedroll...
I'm not really at ease with sin/cos, this is what i'm using but not sure if i'm correct.

 

In the schema:
the big rectangle represent the tent with it's center being the red dot.
the small rectangle represent the bedroll with it's center being the green dot.

 

For MoveTo() i've tried things like that with no success :

 

Bedroll01Ref.MoveTo(self, sin(angle) * (offsetXleft + offsetYfront), cos(angle) * (offsetXleft + offsetYfront), 0.0, false)
or
Bedroll01Ref.MoveTo(self, sin(angle) * offsetXleft, cos(angle) * offsetYfront, 0.0, false)

 

Can someone bring me some enlightment please?
i'm sure the answer is simple and is in front of me (well i hope so!)
Thanks in advance :wink:

Link to comment
Share on other sites

The simplest and quickest way to do this is by pre-placing an "xMarker" where your bedroll should "MoveTo", the xMarker" can also help in pre-align the exact position the bedroll should take when its moved, since it will inherit the xMarkers position/rotation/location.

You script should "MoveTo" the bedroll to the "xMarker" location/target.

Link to comment
Share on other sites

Thanks for the quick reply Maxarturo,

 

I should have given some info:

it's a tent (activator) i place in world from inventory, then i activate it and select how many bedroll i want to spawn.

The xMarker trick will requires me to know exactly where to move it to place my bedroll,

it's on that exact point i don't know, how to get that precise coordinate (the green dot in the schema).

Link to comment
Share on other sites

This is how i done that, by using the tent angle and positions and then i call my function:

 

 

function Bedroll01()

float angle = GetAngleZ()
Bedroll01Ref = PlaceAtMe(Bedroll01, 1, false, true)
Bedroll01Ref.SetAngle(0.0, 0.0, angle + rotateAngleLeft)
Bedroll01Ref.MoveTo(self, sin(angle) * (offsetXleft + offsetYfront), cos(angle) * (offsetXleft + offsetYfront), 0.0, false)
Bedroll01Ref.EnableNoWait()

endfunction

 

 

But it doesn't work has expected :(

Edited by dredd3110
Link to comment
Share on other sites

Start by creating step by step your script, first make sure that the bedroll is placed at the tent's X, Y, Z = 0 axis, then you try to move it to the desirable position.


ObjectReference BedREF = Self.PlaceAtMe(BedRoll, 1)
BedREF.MoveTo(Self, 10.0, 10.0, 10.0, abMatchRotation = true)


After this is done, then you try to put the angle and all the other parameters you want, this way you will know what part is failing in your script.

Link to comment
Share on other sites

I do something similar with my summon npc friends mod. Here's the function I use:

 

float A = pPlayerRef.GetAngleZ()
Float YDist = Math.Sin(A)
Float XDist = math.Cos(A)
YDist *= 200
XDist *= 200
CurrentFriend.MoveTo(pPlayerRef, YDist, XDist, 0, False)
This will place the CurrentFriend NPC 200 units in front of the player. Change the 200 to different amounts for different distances.
For relative angle change float A = pPlayerRef.GetAngleZ() to float A = (pPlayerRef.GetAngleZ() + 90) to place the object directly to the right or (pPlayerRef.GetAngleZ() - 90) to place the object directly to the Left. (pPlayerRef.GetAngleZ() + 180) will place the object behind the player. For your script just use GetAngleZ() like you were doing.
Edit: You'll also probably have to set relative angle z afterwords too. Bedroll.SetAngle(Self.GetangleX(), Self.GetAngleY(), (Self.GetAngleZ() - someAmount))
Edited by dylbill
Link to comment
Share on other sites

Hey,

 

Trying various method and i'm always facing the same problem,

all bedroll appears aligned on the Y axis and don't seem to be offseted on the X axis.

 

I need to dig deeper around math :laugh:

 

edit: I may have found a solution, thanks to Kinaga's Campsite source code.

Edited by dredd3110
Link to comment
Share on other sites

  • Recently Browsing   0 members

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