Check this trajectory prediction. Some math, pseudo code and know how are in posts below.
I hope it helps. Good luck!
Check this trajectory prediction. Some math, pseudo code and know how are in posts below.
I hope it helps. Good luck!
I want to make mechanic similar to Bazooka in Worms - so the launched rocket flying by parabola, and its trajectory depends from initial impuls and randomized wind power.
So what I have now, is a Sphere, which can be stretched back and launched, but its moving by not curved line, like this:
But I want it to move like this, depending from randomly genereated value, which will influence on destination point position (wind):
I assume I should make calculations like this on each tick?:
It’s just I have no idea how
I’m using “Vinterp to” for smoth linear movement, but can it be used for curved movement?
I’m sorry if this is too hard question, but maybe you can at least help me with direction where to dig
Thanks!
Ok, so instead of heading for P1, you need to head for a calculated point on P1-P2, still using tick. Do you have the calculation sort out?..
Nope Looks like I can’t avoid diving into some geometry and math
The “worms” bazooka projectile is not only affected by wind but also by gravity. So you’d have a constant gravity and wind affecting the projectile, not only wind.
The launch gives the projectile some initial velocity, and from that point on, you add the velocity change by both gravity and wind on each tick.
No, I have no gravity, since in my case gravity is directed by Z axis whereas my object is moving only in X and Y axises, so Z (gravity) has no influence on trajectory.
As well as “projectile” is not gonna work in my case, because projectile is designed to move in all 3 axises basing on gravitation (as I can understand), but there is no gravitation in my case.
Anyway, it doesn’t answer my initial question, but thank you for participation in discussion
If X is horizontal and Y is vertical, the reason why the projectile would move in a parabola is the combination of the two forces. There is gravity in worms.
Gravity adds a velocity change in Y-axis, while the wind speed adds a velocity change in X-axis.
But it’s not Look at the example I’ve shown above. The sphere is moving along the flat surface, and I don’t need the gravity influence on it, because the ground is under the sphere in fact. If it will be easy for you to understand, imagine this as a plastic sphere which is drifts on the surface of the water
Thanks, I’ll take a look
I mean, Ok, even if make like you said, this mean I still need to make a wind influence for X axis, right? Because you proposed to use gravity only for Y. So tell me please how to solve it for X axis, and I’ll figure out how to solve it for Y without f**k with a gravity
Well, what he is doing it’s an arc, it’s not a parabola. But it’s something at least. Still I have no idea how to make this logic in blueprints
If you launch the projectile with “Add Impulse”, then once it is launched, you add a force with “Add Force” every tick. It might be better to disable the standard gravity altogether and even just use velocity change and not take mass into account.
You just make a vector perpendicular to one axis, wind velocity on another, add them together, and put it on the add force. You can do it without gravity by adjusting the wind’s direction, but it’s not really the point - the point is, you add to the current velocity every tick once the projectile has been launched.
You need to somehow have a threshold for the calculation of how the wind influences the rocket. This is due to the wind being a random factor in the calculation, or in other words, a variable that changes within a certain range. So, say w is wind, and R is the rocket’s propulsive force at every tick (or throughout its full path), there needs to be a check on both of those per tick. That way the wind influences the rocket correctly. If the wind speed and direction are only affecting the rocket once in its initial straight-line path, then you probably don’t need a bunch of ticks, rather only a few. It would be better to determine the first tick by initial path trajectory (not time), because then the value of it could be plugged into the tick that determines wind influence on the initial trajectory. This means it is calculating the arc or curve which is getting formed by the wind influence, and that the rocket then follows. You really need to look up a formula or equation that is similar to the exact scenario of a horizontally moving object with mass and velocity and how it is affected by a wind variable. It has to be a variable of speed because the wind speed changes during the rocket’s trajectory and influences it still while changing, with wind direction calculated using a vector most likely. Forget about gravity for now since it has a far lesser influence in the scenario depicted by the example. It can be dealt with later after a proper formula or equation (preferably a function equation) is found.
The gravitational field of a planet and its affect on the trajectory of a space ship traveling in a straight line is not the same as the wind affecting a horizontally shot rocket. Depending on the wind direction and its speed, it’s going to create a drag force or a boost force to the launched rocket. That’s where the threshold I referred to comes in. It’s a point of change in the affect of the wind, or the result being rocket’s new trajectory. Using that triangle to calculate an arc is a great idea, but it doesn’t entirely account for wind speed / direction. The kind of function / formula you’re looking for is one that contains a variable for each property involved, and a triangle-based arc would involve too much more unnecessary math. Your challenge is to search for a function / formula that has an initial velocity and straight-line trajectory which is affected by a set of two wind variables (direction and speed). Try a sailboat math search, or a short-distance bullet trajectory formula that is calculating for the influence of wind…just to get the basic function / formula understood. It probably is going to result in a high-school level algebraic function, not some hoity-toity space slingshot theorem.
In case if someone will try to do something similar, I’ve achieved expected behaviour by using UE4 built in physics.
First I turned on a physycal simulation for the sphere, and restricted the axis by which it would be able to move while simulating a physics. The might be made in object details. Also you can set there object’s mass and environmental resistance (it’s not exact name of the parameter, but it’s not hard to determine which one responsible for what, so just play with numbers).
Then I’ve started to add force (there is an appropriate function for this purpose in blueprints) with some power I wanted to, so obect started to move in some direction by the line (it’s not curved trajectory yet).
Then, to simulate a wind, I’ve added one more “add force”, but this time much smaller, although it was adding on each tick, so the longer it moves after launch, the less initial power become, and the stronger influence of the wind become, so in some moment it changes its direction to the one to which the wind was directed.
After that sphere starts to move faster and faster during the time, because forces was constantly adding, but I needed to stop it at some point. So I’ve just added a timer delay, after which a wind stops adding power, and sphere become increasing its speed in natural way.
So here how it works now:
https://drive.google.com/open?id=1P1pZZoU0MwvpnawPAURRP5EMNAlbONoT