Home > other > Consult, seek advice, how to do a parabola bullets
Consult, seek advice, how to do a parabola bullets
Time:09-18
I now do a tank game, shell with a rigid body, the launch of the bullet is a parabola, so the location of the barrel is in front of the camera, the camera has a forward ray can detect the enemy in the gun tube line, used to aim at the enemy, what should I write to get a bullet fired me the camera target to the enemy, rather than the bullet arrive halfway down off Or who is https://blog.csdn.net/hany3000/article/details/9476907? LocationNum=5 of the complete code I wrote out but don't know how to use
CodePudding user response:
Is mentioned in your copy of the position of the two different height, I posted the above said is with the height of the Need a conversion is
Parabola is mirror, setting up stage time and down time as t1 t2 Is the total time of flight height difference between L so L=0.5 g t1 ^ 2-0.5 g t2 ^ 2 t1 + t2=total length, total length, the elimination can solve
CodePudding user response:
,,,,,, small white one I a little could not understand it on the website of the code for the complete code directly to hang in the calling function is good the feeling don't understand
CodePudding user response:
Suppose your tanks and the target object in the same horizontal plane, so the easiest way is to take the halfway point of the tank and the target object directly, you only need to add a constant to shells smaller Y direction of the speed, when reach the midpoint Y direction at a rate of 0, reaches the target Y direction the reverse and emission speed, the speed of this calculation to the simplest (do not use gravity)