dredd3110 Posted May 27, 2020 Share Posted May 27, 2020 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)orBedroll01Ref.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 More sharing options...
maxarturo Posted May 27, 2020 Share Posted May 27, 2020 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 More sharing options...
dredd3110 Posted May 27, 2020 Author Share Posted May 27, 2020 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 More sharing options...
maxarturo Posted May 27, 2020 Share Posted May 27, 2020 If so use the tent as an "xMarker" and move the bedroll using the "Tent's Position", the principle is the same. Link to comment Share on other sites More sharing options...
dredd3110 Posted May 27, 2020 Author Share Posted May 27, 2020 (edited) 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 May 27, 2020 by dredd3110 Link to comment Share on other sites More sharing options...
maxarturo Posted May 27, 2020 Share Posted May 27, 2020 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 More sharing options...
dredd3110 Posted May 27, 2020 Author Share Posted May 27, 2020 I'll try a step by step restart, I've got some free time tomorrow.I would tell you what it done, thanks you :thumbsup: Link to comment Share on other sites More sharing options...
dylbill Posted May 27, 2020 Share Posted May 27, 2020 (edited) 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 *= 200XDist *= 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 May 28, 2020 by dylbill Link to comment Share on other sites More sharing options...
dredd3110 Posted May 28, 2020 Author Share Posted May 28, 2020 Thanks Dylbill for the info :thumbsup:I test that tonight. Link to comment Share on other sites More sharing options...
dredd3110 Posted May 29, 2020 Author Share Posted May 29, 2020 (edited) 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 May 29, 2020 by dredd3110 Link to comment Share on other sites More sharing options...
Recommended Posts