johnnyboy 3793 Posted January 28, 2007 I need a script to calculate the position of one object relative to another. I am near certain that this function was posted on OFPEC, but that site has been down for days now. Can someone please post the function here? Thanks! Share this post Link to post Share on other sites
johnnyboy 3793 Posted January 29, 2007 Thanks T_D, that is a related command, as you input two objects, and it will tell you the relative x,y,z values that gets you from one object's position to another. What I'm looking for is you input one object, and the relative x,y,z values, and it returns the position relative to that object (so I can then setpos an object to that relative position. Specifically what I need is a function that takes this input: - An object - x value relative to the object - y value relative to the object The function calculates and returns a position relative to the object. For example, if I pass these values: Player, 2, -3 The function gets the position of the player, gets the direction of the player, and adds 2 the y position (adjusting it for player object direction, as if the player object direction was zero), and subtracts 3 from the y value (adjusting for object direction again. Its trigonometry, using sign and cosign...but I suck at math and hate to reinvent the wheel. Example usage: You want to place an object 3 feet behind, and two feet to the left of the player. This function was on the OFPEC website for download. Share this post Link to post Share on other sites
t_d 47 Posted January 29, 2007 Ah you mean the other way round: modelToWorld Share this post Link to post Share on other sites
tj72 0 Posted January 29, 2007 camsetrelpos will place objects relative to another. If you have a unit and you want to place a marker or object say, 50 meters ahead of where he is facing at anytiime, this command will work. Its in COMREF. I dont have any code examples handy but I can get it if you need. Its a handly little command and the only other way would be through some kind of trig solution. Share this post Link to post Share on other sites
t_d 47 Posted January 29, 2007 Or you use modelToWorld Example: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_relPos = [2,-3,0] _worldPos = object1 modelToWorld _relPos object2 setpos _worldPos This would set object2 relative to object1. Share this post Link to post Share on other sites
johnnyboy 3793 Posted January 29, 2007 Awesome! That's exactly what I need. Thanks a million you guys. Share this post Link to post Share on other sites
tj72 0 Posted January 29, 2007 T_D is that command for ARMA only? Im stuck in OFP mode. But Id like to check that command out when I get a chance. \Edit: Nevermind I see its ARAM only. Share this post Link to post Share on other sites