Calculating trajectory for a throw (Game-programming)

Click For Summary
The discussion revolves around calculating the trajectory of a snowball throw in a game, focusing on visualizing the arc before the throw. The user has established variables such as launch point, angle, gravity, and force but struggles with implementing the trajectory tracing in Unreal Engine 4 due to limited documentation and a closed physics backend. Suggestions include studying projectile motion and utilizing a physics simulation to predict motion, although the user prefers not to include wind effects. The main challenge lies in accurately representing time in the calculations for displacement without running simulations. Overall, the user seeks assistance in refining their trajectory calculations for better visualization.
OyvindAndersson
Messages
2
Reaction score
0
Hello, and +1 for this great forum!

I have encountered a small problem in my way of creating a small game. I have a snowball that is being thrown by the player. The dynamic variables from the input of the player are: Force and angle (between 90 : -90 degrees). At the moment I apply the force like so:

16007435626_603dba6405_o.jpg


The force is spent in 2 dimensions (Z and Y axes for up/down, left/right). Anyway, that is working quite well, and I'm happy with the result. But what I need is to draw some graphics on the screen to simulate the trajectory the ball will take before it is thrown. Not all the way, but an indication of how the trajectory will be.

If you know the game "Peggle" (perhaps angry birds also?), it is much like that.

Variables I have: Point of launch (vector), angle/direction, gravity vector, and the force that is divided between both the Z and Y axes and mass of the ball (kg).

If any of you could help me calculate the arc of the trajectory so that I could visualize a part of it, I would be very grateful. Alas my math skills does not stretch that far.Oyvind
 
Physics news on Phys.org
OyvindAndersson said:
If any of you could help me calculate the arc of the trajectory so that I could visualize a part of it
A trajectory with no drag is quite simple to compute, as shown in the wiki link.

But ideally that engine you use would support a background physics simulation, where you can add a virtual object to your world and simulate a few seconds of it, in every frame of your actual simulation, to plot it's predicted motion. That would encompass additional affects you might add to your game, like aero drag and wind. You should ask in a forum specific to that engine if there is a functionality like that.
 
Thanks a lot for the reference. I replaced my previous calculation of the impulse to the formula found on that wiki link.

@A.T.
I'm having some trouble implementing the tracing, however. The physics backend in Unreal Engine 4 is somewhat closed off, and the documentation for what is currently exposed is lacking. Therefore I have some trouble simulating the throw virtually.

The upside however, is that I have not - and will not - add in wind. The only thing affecting it is the gravity, initial velocity and the mass of the ball.

I tried to get the displacement at different lengths, but I must have borked the forumla somehow. I think [time] is what is confusing me a bit. Since I'm not doing any simulations, how would I present time??Øyvind
 
For simple comparison, I think the same thought process can be followed as a block slides down a hill, - for block down hill, simple starting PE of mgh to final max KE 0.5mv^2 - comparing PE1 to max KE2 would result in finding the work friction did through the process. efficiency is just 100*KE2/PE1. If a mousetrap car travels along a flat surface, a starting PE of 0.5 k th^2 can be measured and maximum velocity of the car can also be measured. If energy efficiency is defined by...

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 14 ·
Replies
14
Views
4K
Replies
5
Views
5K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
3
Views
2K
  • · Replies 38 ·
2
Replies
38
Views
4K