InqWiper 0 Posted June 6, 2004 The guided missiles in OFP all fly beside the crosshair when you guide them. Is there anyway to make the missile fly in the crosshair so the missile will hit the target if you aim on the target and not 30 meters beside it? I dont want a script that locks onto a vehicle and then guides the missile to it. I tried making a camera infront of the player at the same distance as the missile to get the position the missile should be in .The problem was that the player is not facing the same direction as the launcher or the vehicle turret is not facing the same way as the body. Can anyone help me with this? pleeease  Share this post Link to post Share on other sites
newiy 0 Posted June 8, 2004 Not sure exactly what your problem is... But if I may venture a guess, is the problem is trying to find the correct angle to face the camera? If that is the case, then 1) Get the relative position of the target to the player: This can be done by subtracting the corresponding coordinates in the following fashion: Relative x = Target x - Player x Relative y = Target y - Player y Relative z = Target z - Player z 2) The angle you want is atan (Relative x/ Relative y) Good luck ;) Share this post Link to post Share on other sites
InqWiper 0 Posted June 8, 2004 Thanks for the answer but the problem is that there is no target. I want a missile that when guided tries to stay in the middle of your sight and not beside it. When you first fire a guided missile it will be almost in the middle of your sight but when you aim for example to the left the missile will fly to the right of your sight. I want the missile to fly in the middle when I aim around. Share this post Link to post Share on other sites
newiy 0 Posted June 9, 2004 Since I'm clueless as to how missles are actually supposed to fly IRL or the math behind it, this is guesswork. In that case, I believe instead of target, you find the relative position of the player to the missle. Since a missle is 3d, you'll have to find two angles... You have to set up a loop to do the following... second angle will be: Alpha = atan (Relx_missle/ Rely_missle) Beta = atan(Relz_missle / sqrt(Relx_missle^2 + Rely_missle^2)) From these angles, find how much it is off. Then using the missle's current relative velocity, try to get the missle's relative x and z components to 0. Using alpha and beta, find the desired correction direction on the missle's relative velocity... (if Relx is neg then the correction should be in the positive x direction... same goes for the z component) The magnitude of the correction is entirely up to how you want the missle to fly. You might want to change the real y component of the velocity in order to maintain a constant speed: The y after correction should be: sqrt (speed - New REAL x - New REAL z) Don't forget to change relative velocity back to actual velocity before assigning it to the missle! Not sure if this will work, but I believe it should. If you succeed, the missle won't exactly fly in the centre of the crosshair, but zig zag like crazy, unless you defined the magnitude of the corrections nicely (not sure how to do this, but it sure can't be constant). If there's another solution, I'm interested too. Share this post Link to post Share on other sites
InqWiper 0 Posted June 9, 2004 I tried what you said and I didnt get it to work. I tried some others things too and when the missile is forced into the center of the crosshair it wants to go back out again even if you dont move the crosshair. Share this post Link to post Share on other sites
newiy 0 Posted June 10, 2004 Did you try tweaking the magnitude of the corrections? The idea is to reduce the magnitude as the missle approaches the crosshair so it doesn't overshoot. Anyhow, I'm all out of ideas at the moment. Share this post Link to post Share on other sites
sa8gecko 0 Posted June 11, 2004 InqWiper: if you're trying to get guided missile in an addon, you can give a look at the MCAR files: OFPNews there should be something that may suit you, in the scripts.pbo file. Or anyway should give you an idea. Share this post Link to post Share on other sites
InqWiper 0 Posted June 11, 2004 Quote[/b] ]you need missile cam? No. What I want is a missile that stays in the middle of the crosshair when I stear it. I tried the MCAR addon but those missiles didnt stay in the middle of the crosshair as far as I can remember. Share this post Link to post Share on other sites
Skewballzz 0 Posted June 11, 2004 make the missile follow an indipendant Laser dot. Â Just make it so whenever u shoot the missle will follow its laser, or what is perceived to be the crosshair. Â I dont know if it will stay directly in the crosshairs though Share this post Link to post Share on other sites
InqWiper 0 Posted June 11, 2004 I was planning to make one of my final tries involve a laser but I would rather solve it in some other way. The idea is to switch the launcher to a laser designator, get the position of the player, get the position of the laser dot and get the missiles distance from the player and that way find out where the missile is supposed to be. It will not look very good switching it to a laser designator so I prefer not to do that. Also you could have a laser designator from the start and launch the missile with the action menu. Another idea is to use some sort of MG with no recoil and get the direction of the bullets it fires to know which direction the missile should be flying. I think none of those 2 solutions are very good so its like a last resourt if its even worth it Share this post Link to post Share on other sites
sa8gecko 0 Posted June 12, 2004 InqWiper: Quote[/b] ]I tried the MCAR addon but those missiles didnt stay in the middle of the crosshair as far as I can remember. try the 'hmmwv tow2a real' (or something like that) and fire at a target that cannot be locked by the guidance code, i.e. a ship or a man, placed at 2000 meters away. Then move the crossair (maybe using the 21x sight) and watch the missile follow it (allow some time if you're moving the crossair swiftly, as the missile has not an instantaneous turning rate). You should be able to guide the missile very precisely. If you need to modify the scripts so that there's no target lock, IM me. Share this post Link to post Share on other sites