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)

CodePudding user response:

Do with X-ray laser tanks?

CodePudding user response:

Without gravity is not good

CodePudding user response:

reference qq_40802974 reply: 3/f
,,,, small white one I a little could not understand it on the website of the code for the complete code can ah hung on directly calls the function is good feel understand

I do all of these are his junior middle school physics review
it is not difficult to underOnly one more dimension, then the velocity and acceleration are three dimensional vector, can break up

CodePudding user response:

Add a script on shells, each frame reset forward position,
Public Vector3 Vect;//record a frame position
Void the Start ()
{
Vect=the transform. The position;
}
Void Updata ()
{
If (the transform position!=Vect)
{
The transform. Forward=the transform. The position - Vect;
}
}

CodePudding user response:

Add a rigibody gravity component on the bullet, hook use under gravity

CodePudding user response:

This is a false proposition
If you want to have physical shell that is equivalent to the real conditions of simulated
Who can accurately judge the placement of shells? What do you mean by screen prospective heart there is no
If you want to just simple ray collisions, parabola is auxiliary, it doesn't matter, the junior high school knowledge to go
Constant speed in a horizontal direction
A vertical direction on the...