Working on a simple(ish) projectile motion problem for a gaming program

In summary, the conversation is about a Unity 3d game project and the need for physics guidance. The individual wants to extend a simple physics formula for a perfect interception and is struggling with the mathematical reasoning. They discuss using an equation to find the intercept of a projectile fired from a moving platform at a target. They consider various factors such as gravity and acceleration, and work through equations to solve the problem. Ultimately, they come up with a simple solution that involves working in terms of relative position and using vector equations.
  • #1
Jay123
3
0
Hello ladies and gentlemen I am working on a Unity 3d game project and I am in need of some physics guidance. You probably know Unity3d has a built in physics engine, and if you don't you do now. :)

I am determined to figure this out more or less on my own but I need some assistance with the mathematical reasoning.

In the past I used an website as guidance to implement a simple not-very-realistic simulation in Unity as proof of concept.

This is the website:

https://indyandyjones.wordpress.com/2010/04/08/intercepting-a-target-with-projectile/

However I would like help in extending this beyond simple physics to become a perfect interception formula.

Right now I am working to factor in the movement of the platform (with off-the-forward axis projectile shooting) performing the shoot down and the motion of the projectile to be fired at.

If you read the link provided you will understand how the author reasoned to a solution.

That is the part that I have trouble with. That, recalling all of my math education without resorting to my notes. I can do algebra just fine but Undergrad has been a real struggle. Its a long story. :)

So I just need some coaching about how to go about finding the intercept of a projectile fired from a moving platform at a missile (other projectile) flying in any direction near it (preferably within range and direction to intercept reliably).
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
Some details are unclear.
Is this in two dimensions or three? I expected three but the link describes the bullet as though moving in a plane: "The set of all possible positions that the bullet could be located at for any given time forms a circle around its original location". In 3D it forms a sphere around a point somewhat below its firing position.

What is the nature of the target's motion? Is that a constant velocity? If in 3D, is it not also subject to gravity?
 
  • Like
Likes Jay123
  • #3
This is quite simple. Create a variable time defined as the time it takes for the ball to go up and then down in the y-direction. Use this variable to create a new variable about how far it goes in the x-direction on terms of the previous variable. You can have all kinds of variables depending upon what you want. Just slowly think it through and write down all the equations.

I'm sure you are aware of the kinematic equations. Is the question in 3d like @haruspex thought?
 
  • Like
Likes Jay123
  • #4
Hey guys I've been asleep. Anyway in response to @haruspex those are good questions, something I forgot to provide initially.

For my first Unity demo I aimed to get it working in 2 dimensions, with constant, linear velocity. At some point I'd like to factor in acceleration, rotation, and right now: firing off axis from a moving platform (ie. the movement vector of my platform affects the shot trajectory due to inertia).

Oh and there is no gravity! I hadn't even thought of that but it may be a good future feature to work on. :)

I do not know of these kinematic equations tbph, I am not versed in physics which is why this seemingly simple problem is not getting easily solved by myself. I am a math minor, not a physics. :)
 
  • #5
Jay123 said:
get it working in 2 dimensions
Easy. Work in terms of relative position.
The initial position of the target relative to the projectile is some vector ##\vec s##. If the target moves with velocity ##\vec u## and the projectile with velocity ##\vec v##, what is the relative position vector at time t?
For intercept, what equation can you write? Being a 2D vector equation it is effectively a pair of simultaneous equations. If you fix the magnitude of ##\vec v## the unknowns are the direction and the time.
 
  • Like
Likes lekh2003
  • #6
This projectile problem is even simpler than before since not only is there no gravity, there is no acceleration altogether. I'm also assuming both projectiles move at the same speed. All of these facts make this problem phenomenally easy.

Assuming the above facts, the projecticles can only intersect each other at a point equidistant to the projectile launch points. So I thought up a few equations. Assuming that the trajectory of a projectile launched from coordinates (0, 0) is in the form ##y=mx##, then the trajectory of the intersecting projectile launched from coordinates (a, 0) is in the form ##y=-mx+am##.

Does that make sense?
 
  • #7
haruspex said:
Easy. Work in terms of relative position.
The initial position of the target relative to the projectile is some vector ##\vec s##. If the target moves with velocity ##\vec u## and the projectile with velocity ##\vec v##, what is the relative position vector at time t?
For intercept, what equation can you write? Being a 2D vector equation it is effectively a pair of simultaneous equations. If you fix the magnitude of ##\vec v## the unknowns are the direction and the time.

Absolutely. Its just a line equation dependent on the time 't' with vectors for the position and velocity...
 
  • #8
Jay123 said:
Absolutely. Its just a line equation dependent on the time 't' with vectors for the position and velocity...
Except, I forgot you have a moving platform, so you need another constant vector for that in the equation.
 
  • #9
haruspex said:
Except, I forgot you have a moving platform, so you need another constant vector for that in the equation.
Yeah I seemed to have missed that too. I'm now assuming from OP's responses that the velocities are not the same. So that's just more variables, the more the merrier.
 

Related to Working on a simple(ish) projectile motion problem for a gaming program

1. What is projectile motion?

Projectile motion is the motion of an object through the air or space under the influence of gravity. In simpler terms, it is the path that an object takes when it is thrown or launched into the air.

2. Why is projectile motion important in gaming programs?

Projectile motion is important in gaming programs because it allows for realistic and accurate simulations of objects in motion. This is especially important in games that involve shooting or throwing objects.

3. How do you calculate the trajectory of a projectile in a gaming program?

The trajectory of a projectile in a gaming program is calculated using the equations of motion, which take into account the initial velocity, angle of launch, and acceleration due to gravity. The trajectory can also be visualized using vector components and trigonometry.

4. What factors can affect the projectile motion in a gaming program?

There are several factors that can affect projectile motion in a gaming program, such as air resistance, wind velocity, and the surface or terrain the object is launched from. These factors can alter the trajectory and make the simulation more realistic.

5. How can projectile motion be optimized in a gaming program?

To optimize projectile motion in a gaming program, precise and accurate calculations must be made using the appropriate equations and factors. It is also important to consider the limitations of the gaming program and make adjustments accordingly to ensure a realistic simulation.

Similar threads

Replies
4
Views
1K
Replies
3
Views
4K
Replies
6
Views
1K
  • Programming and Computer Science
Replies
7
Views
1K
  • Introductory Physics Homework Help
Replies
19
Views
2K
  • Advanced Physics Homework Help
Replies
6
Views
869
  • Introductory Physics Homework Help
Replies
6
Views
867
Replies
14
Views
2K
Replies
4
Views
11K
Back
Top