Learn how to use Lua missiles. The code: pastebin.com/A5M6BUJf
Пікірлер: 61
@ChristopherMocko3 жыл бұрын
I'm a mechatronic engineer and was able to mostly follow along with this. I know it would be extra work on your part, but explaining the vector math with diagrams would make this a lot easier to understand for more casual (or younger) players. This is a great video though. I'd be interested to watch you play through one of the campaigns.
@andregaspar75533 жыл бұрын
Amazing! Thanks for sharing your knowledge! Look forward to see more of these guides.
@keithkienzle45403 жыл бұрын
Thank you for the wonderful tutorial, I've always struggled to understand how to set up lua. This video was the most helpful guide i've found.
@jaiminlyons34823 жыл бұрын
Found the tutorial at just the right time can't get my copy pasted lua to work. Can't wait for part 2
@barefootalien3 жыл бұрын
Yas! Definitely looking forward to the more sophisticated versions!
@nicopence31483 жыл бұрын
Looking forward to all those advanced guidances. Since those missiles are going so straight, you will need less fins freeing up space there as well. When I tried to do this a couple years ago I had no idea about these helper functions and little knowledge of vector math which resulted in me giving up on LUA. Thanks for showing me that it's very achievable and useful so I'll take a crack at it again.
@Blyter7 Жыл бұрын
i made a proximity fuse version for air targets: function Update(I) target_position = I:GetTargetInfo(0, 0).AimPointPosition target_velocity = I:GetTargetInfo(0, 0).Velocity proximity_radius = 10 -- Adjust this value to set the proximity radius time_threshold = 2 -- Adjust this value to set the time threshold for detonation after passing the target for t = 0, I:GetLuaTransceiverCount() - 1 do for m = 0, I:GetLuaControlledMissileCount(t) - 1 do missile_info = I:GetLuaControlledMissileInfo(t, m) missile_position = missile_info.Position missile_speed = Vector3.Magnitude(missile_info.Velocity) target_distance = Vector3.Distance(target_position, missile_position) target_vector = Vector3.Normalize(target_position - missile_position) relative_speed = missile_speed - Vector3.Dot(target_vector, target_velocity) lead_factor = 1.5 -- Adjust this value to control the amount of lead prediction = target_velocity * target_distance / relative_speed * lead_factor point = target_position + prediction I:SetLuaControlledMissileAimPoint(t, m, point.x, point.y, point.z) -- Check if the missile has passed the target and exceeded the time threshold if target_distance time_threshold then -- Detonate the missile I:DetonateLuaControlledMissile(t, m) I:LogToHud("Missile detonated at proximity radius and time threshold") end end end end
@AvnerSenderowicz3 жыл бұрын
so the missile really does know where it is by substracting it from where it isn't.
@scottwright71773 жыл бұрын
Subtracting two points will give a direction and distance. I think that’s what you’re asking.
@MrJay_White3 жыл бұрын
@@scottwright7177 its a reference to an old joke /watch?v=bZe5J8SVCYQ
@RevolverOcelot792 жыл бұрын
Fantastic video, sir! Any idea when part 2 will released?
@andreipoplauschi1808 ай бұрын
This might be late but i wanted to thank you for this tutorial, i am working on a new Missile AA platform and will use your code for the missiles, might add some other stuff later on
@RandoNetizen272 жыл бұрын
Can't wait for part 2
@riancox782 Жыл бұрын
Great video! The are two things that would be great to have tutorials on. They both stem from FtD targeting and guidance systems not taking into account water drag (for crams) nor gravity's altitude dependence. The first is tutorial is for semi ballistic or high altitude launched lau glide 'bombs' with the most difficult type effectively being a drone that acts as a interceptor decoy while getting into a good position and heading relative to the target for the most effective use of its payload of short range missiles or mines (example 1: A glide bomb with payload of short range one-turn single pixel AA missiles to set off enemy flares and get the AA missiles behind an enemy jet which is too far away for accurate vehicle based detection. Example 2: Glide bomb that looks at life-time vs time-to-target and computes whether to glide or dive, taking into account that the gravitational field strength and air resistance varies with altitude.). The second tutorial would be using lua to aim CRAM cannons
@spac3drunk2833 жыл бұрын
I usually find not worth the trade of from "normal" to lua, due to the place and price used by general processing power cards. But I still use lua for special kind of missile. For exemple I got a huge missile how purpose is just being a lump of metal with a heck of health to distract CWIS, and circle (above or under the target, depending if it's a aircraft or a boat). And lua is pretty much the only way to do that.
@_mwk2 жыл бұрын
Big thanks, very helpful
@aaaowski7048 Жыл бұрын
thanks for the video. very explicative.
@TecHnosMark3 жыл бұрын
FINALLY LUA MISSLES, THANKS !!!!
@funcaronq50973 жыл бұрын
You got a new sub :)
@uroskra772 жыл бұрын
Hey Scott, thnx for this video. Pretty please if you can do a next video on this subject, especially for "rain from above" code that you have on Pastebin. Thank you!
@asrieldreemurr50293 жыл бұрын
Good video, but that's not the right way to calculate the closing velocity of missile and target. First you should subtract target velocity from missile velocity, then do the dot product: the way you did it you overestimate the closing velocity as you assume the missile is heading straight for the target, and for fast targets requiring a significant amount of lead that can result in enormous errors. You got very lucky with your dummy target, as the lead error introduced by its acceleration (which would make the missile lead too much) is of opposite sign to the error introduced by your LUA code (which would make the missile lead too little) so the total error ends up being small. Also the vanilla prediction guidance module is just broken: looking at the decompiled code, it doesn't even try to take the target's velocity into account to determine time to impact, it just does relative distance divided missile max velocity.
@drunkengibberish11433 жыл бұрын
I thought I was a smart cookie, being the first one to solve problems in computer science D:
@drunkengibberish11433 жыл бұрын
Could you please provide an example of how you would implement this fix? Whenever I tried it would usually end up in an error
@asrieldreemurr50293 жыл бұрын
@@drunkengibberish1143 it's really easy, just make sure you're using the actual vector3 values and not their magnitude.
@scottwright71773 жыл бұрын
I think you would end up with major overcorrection as the missile turns towards the target. Your missiles would arc in the opposite direction as they approach and defeat the purpose. They would have the disadvantages of guided and non guided. I even go a step further away from your suggestion by hard coding my missiles’ average speed. This will prevent overcorrection as it turns into the target or speeds up. Near the target, I use the real speed.
@asrieldreemurr50293 жыл бұрын
@@scottwright7177 you'd think wrong, "my" suggestion is an alternative formulation of proportional navigation and that's known to be optimal within its constraints. If you don't trust the math, try your missile against a target with a different acceleration profile, for example the same test target circling at some distance from the launchpad instead than right around it. Or just try agains a sufficiently fast target that moves in a straight line, you'll consistently see your missile fall behind it.
@turnerd203 жыл бұрын
could you do a video on useing the PID modules? and building a space station? really struggling with it
@emanuelgendusa31815 ай бұрын
where's part 2 a long time ago I heard someone made LUA torpedoes that went under ships and attacked directly from beneath basically the opposite of the one "like artillery" you mentioned
@FuturPlanet2 жыл бұрын
Im programming in Unity. Helped a lot to understand. Thank you
@aetwit2 жыл бұрын
came back again hoping for a follow up and sad to see no followup.
@elementalgolem54983 жыл бұрын
so i have a problem with mine "over predicting" they seem to consistently miss infront of the target by 4-6 blocks and i cant find a fix for it
@darth_dan88862 жыл бұрын
Part 2 when? XD Am currently trying to figure out how to take gravity into account for an orbiting missile. This vid certainly refreshed my memory on stuff like game tick length.
@scottwright71772 жыл бұрын
I'm sorry, everyone, for the silence on FtD videos. I'll see if there is any time to get back into the game and finish some of what I started. I've been busy... really busy. I mean I've been helping start up a company, moving, finishing my Master's, and now raising a daughter. It's been over a year since I've touched FtD.
@IamusTheFox Жыл бұрын
@@scottwright7177 Good luck on the startup. Congratulations on your daughter. Hopefully your Master's isn't taking too much out of you!
@Frost-013 жыл бұрын
by chance do u know how to make a pop up sea skimming missile?
@MrJay_White3 жыл бұрын
where do you find the terms to put in? is it under help? i have pretty much treated lua as a pandoras box full of daemons and mischief hat i should just leave alone.
@javik19293 жыл бұрын
same, also the breadboard but getting into that only took like 2h which is pretty much nothing in this game :D just go for it
@anubismacc81657 ай бұрын
Where's Part 2 ??
@pieman530973 жыл бұрын
Is there a way to do a guidance delay on LUA missiles? I want my missiles to fly straight for like 1-2 seconds before turning
@scottwright71773 жыл бұрын
Yeah, have a list of missile timers outside the Update function that follows the same index patterns as the missiles. Check if the timer is 1-2 seconds before using the code.
@ComandantChaos3 жыл бұрын
from a dev standpoint (not math oriented) i would say your explanation are close to perfect :) i would just have renamed `t` to `transmiter` and `m` to missile for readeability but otherwise your explaination were realy nice
@inscseeker4013 жыл бұрын
Question: are we assuming that the velocity is based on the vector of the enemy generated by its movement in one second?
@scottwright71773 жыл бұрын
One frame, or 1/40 of a second.
@inscseeker4013 жыл бұрын
Thanks, also very nice useful tutorial! (Trying to make a predictive guidance interceptor missile here)
@JamesCZFEA3 жыл бұрын
Is there a way to code a lofted trajectory as in fly at 800m then when closing in come down and strike from above? I noticed the older code to do this is fairly broken
@scottwright71773 жыл бұрын
pastebin.com/szFs7u2x See if this works, but change y=3 to y=800. You may need to mess with the P and D values in {Error = 0, P = .05, D = .02}
@JamesCZFEA3 жыл бұрын
@@scottwright7177 thanks I will give this a try
@JamesCZFEA3 жыл бұрын
@@scottwright7177 Works really well thanks
@carlvongames69263 жыл бұрын
@@JamesCZFEA do you still have the code for the javlin version I want to play around with huge ap mega javlin
@JamesCZFEA3 жыл бұрын
@@carlvongames6926 the code Scott linked works fine, I did not have to mess with the P and D values
@savman42423 жыл бұрын
You seem to be well versed in LUA. I've got an interesting idea for a project but I don't know the coding to do so. would you mind helping?
@scottwright71773 жыл бұрын
What is it?
@savman42423 жыл бұрын
@@scottwright7177 I need to use a LUA box to detect the health of a construct, the nearest one if it's not specific or an indexed one if possible. Then I need it to trigger a complex controller for me. Is that possible? I know you can get the Health Fraction of a friendly but if there's multiple of them can i choose which. Do you have discord by chance?
@scottwright71773 жыл бұрын
@@savman4242 discord.gg/g3EAme89
@miltoska97082 жыл бұрын
Still waiting for part 2
@WolvesAssault2 жыл бұрын
I tested medium & small missiles vs fast over 150m/s small planes keep missed only few hit not good vs fast small planes only good vs big slow plane/airship under 110m/s & only worked small missiles vs under 110m/s small planes. Best laser & 1000m/s ballistic vs small fast planes over 150m/s. I used EMP small missiles vs under 110m/s small planes go BOOM! AI dead is awesome lol.