c# - Hit incoming missile (simple projectile missile) in Unity3D -
i want make surface air missile system in unity3d predict incoming missile position after time 't' , set interceptor missile angle , position in 3d coordinates hit incoming missile. using following function prediction of incoming missile.
void updatetrajectory(vector3 initialposition, vector3 initialvelocity, vector3 gravity) { int numsteps = 500; float timedelta = 1.0f / initialvelocity.magnitude; linerenderer linerenderer = getcomponent<linerenderer>(); linerenderer.setvertexcount(numsteps); vector3 position = initialposition; vector3 velocity = initialvelocity; (int = 0; < numsteps; ++i) { linerenderer.setposition(i, position); position += velocity * timedelta + 0.5f * gravity * timedelta * timedelta; velocity += gravity * timedelta; } }
i using line renderer visual trajectory display. can hit missile @ few position means :p have adjust manually. sam missile system set angle can't set exact time , velocity hit missile.
you need professional: exponential curve fitting.
http://mathworld.wolfram.com/leastsquaresfittingexponential.html http://mste.illinois.edu/malcz/expfit/first.html
you points curve , find coefficients of curve extrapolate next point. algorithm seems little linear whole curve true latest points , not enough.
alos known non-linear regression.
here, stackexchange answer: https://stats.stackexchange.com/questions/20271/exponential-curve-fitting-with-a-constant
Comments
Post a Comment