Need Help with trajectory based game equation

In summary, the conversation discussed a trajectory-based game and the relevant constants for the game, including g = 1 and v = 0.287p. The main question was how to measure and find the values for X and Y in the equation angle = atan((v^2 +/- sqrt(v^4g(gx^2+2yv^2)))/gx). Suggestions were given to check the DPI of the screen and measure the number of pixels using a screenshot. The conversation also touched on the origin of the equation and the units of g and v.
  • #1
CheatyFace
9
0

Homework Statement



i Pmed some mentors but they said i should post it at forum, i asked Astronuc that if its ok to post this in forum and he told me to post it in this section.. i know some users here are very senior and surely have the knowledge to this and i want to learn. it is a trajectory based game where you shoot an object up in air and it should hit the ground where your target is located (where you want it to hit) so you have to fix the angles, distance of you and your target and how deep/high your target is in order to you.. as the speed is always constant FULL POWER. this equation is at nr.2

Homework Equations




angle = atan((v^2 +/- sqrt(v^4g(gx^2+2yv^2)))/gx)


The Attempt at a Solution



for this game the relevant constants are:
g = 1, v = 0.287p, where p is a value from 5-100 (5 is minpower, 100 is maxpower). Distances are in pixels. for one reason: Shooting at max power (full bar) eliminates any measurement error in determining the muzzle velocity of the projectile, as firing at maximum power guarantees that p is always exactly 100.

Example of how the game works..

here you can see me shooting few shots and then aiming and trying to hit the target it takes me 3-4 tries to fix the angle and hit perfect.. but using the above equation, putting in distance, height/weight of target, it would give you an angle to shot in (full power) and it would hit your target with just 1 try..

another video different map.

WHAT IS THE PROBLEM? : i am wondering which values to put in x and y.. i am guessing x would be the Distance between me and the target and Y would be the how deep/high the target is.. but how should i find x and y? if i use a ruler to find the distance between me and Target it would give me in cm/inches so should i put x in cms or must i convert it to Pixels? i have almost solved it out, just need help with what values i must put in x and y.

solving the above equation would give a angle to shot in. I can also give reward to the one who helps me, Astronuc said it is not allowed to give reward to homework helps, but this is not kinda homework its something different so let's c if anyone can help.
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
If your grid is in pixel , put in pixel
 
  • #3
^how do i convert cm to pixels?? and my screen resolution is 1920 x 1080
 
  • #4
any1?
 
  • #5
hellow , cheaty
The thing is DPI ( dots per square inch)
You need to know how much pixels are there per inch or cm^2 , depending on your preferance .
If you know the area of your screen , you get the ratio to convert pixels in cm .
http://members.ping.de/~sven/dpi.html
 
  • #6
This website did not show my screen's diagonal correctly , since I know its 15 I put that value in the website . You check yourself the diagonal of you screen in inches .
 
  • #7
CheatyFace said:
angle = atan((v^2 +/- sqrt(v^4g(gx^2+2yv^2)))/gx)
Where did you get this equation?
 
  • #8
Doc Al said:
Where did you get this equation?

the equation is from "Angle θ required to hit coordinate (x,y)" taken from Wikipedia..

here: http://en.wikipedia.org/wiki/Trajectory_of_a_projectile#Angle_required_to_hit_coordinate_.28x.2Cy.29

8380d78ccac32ae4bcfdb6f3ef840613.png
 
  • #9
Are you designing a game or are you trying to figure out how a particular game works?
 
  • #10
voko said:
Are you designing a game or are you trying to figure out how a particular game works?

i am trying to study the game and i am soo close to it just need a small push.. as i have already found out which equation should be used and WHAT are the relevant constants for that game: g = 1, v = 0.287p and where P is always 100 (MAX POWER) now i need help with how should i find the X and Y. which values to to sit instead of X and Y.. i am guessing x would be distance and Y would be the height of target. but how should i measures the X and Y that is my main question..
 
  • #11
How did you get g and v? What are their units? x and y should be in the same system of units.
 
  • #12
voko said:
How did you get g and v? What are their units? x and y should be in the same system of units.

g = gravitational constant (which is 1 for this game)
v = velocity (0.287p, where p = 100)

x = distance from entity
y = difference in Y position from entity and player

the question is how should i measure and find x and y..
 
  • #13
The question is where did you get g and v and their units.
 
  • #14
This is the equation for angle
 

Attachments

  • 8380d78ccac32ae4bcfdb6f3ef840613.png
    8380d78ccac32ae4bcfdb6f3ef840613.png
    1.6 KB · Views: 385
  • #15
Sorry for png file
this one looks good
 

Attachments

  • 8380d78ccac32ae4bcfdb6f3ef840613.jpg
    8380d78ccac32ae4bcfdb6f3ef840613.jpg
    4.1 KB · Views: 438
  • #16
kushan said:
Sorry for png file
this one looks good

yeah i have posted the equation see post nr.8 my problem isn't that... i need to know how to measure X and Y.. how do i measure X and Y. as X = distance of me and target and Y = height of me and the target.. if i use a ruler i would get it in cm must i convert it to Pixels? and as my screen resolution is 1920x1080 how do i find what will be the DPI?
 
  • #17
Why don't you try measuring it directly? Follow what is said on this wiki page: Pixel density
 
  • #18
One way you could measure the number of pixels is to make sure the game is set to its actual size (not stretched) and take a screenshot. Crop the part of the screenshot that you want to measure, and check the dimensions of the image.

If you want to be able to use a real distance measurement (I.E. inches), measure the width of the image on your screen; You can use your two measurements to make a proportion for pixels/inch, and you can use this as a conversion factor. Keep in mind, though, that this conversion factor will only work on your monitor, or one with the same pixel density.
 
  • #20
kushan said:
Dude I gave you this website
http://members.ping.de/~sven/dpi.html

It will tell your DPI

how much i try to change the Diagonal won't change...my screen is 1920x1080 i don't know if it gives me the right value or not because even if i put some random numbers the diagonal won't change at all..
 
  • #21
Dude take a scale and measure your diagonal , and put that value there .
Rest is being taken care of at that website .
 

FAQ: Need Help with trajectory based game equation

What is the trajectory equation used for in a game?

The trajectory equation is used to calculate the path of an object in a game, such as a projectile or character, based on its initial position, velocity, and acceleration. This helps create realistic movements and interactions within the game world.

How is the trajectory equation different from other equations used in games?

The trajectory equation is specifically used to calculate the path of an object in motion, while other equations may be used for different aspects of the game, such as collision detection or character movement.

What factors affect the trajectory of an object in a game?

The trajectory of an object in a game can be affected by various factors such as initial velocity, gravity, air resistance, and any other external forces that may be present in the game environment. These factors can be adjusted to create different trajectories for different scenarios.

How accurate is the trajectory equation in predicting the path of an object in a game?

The accuracy of the trajectory equation depends on the complexity of the game and the variables taken into account. In simpler games, the equation may provide a very accurate prediction of the object's path, while in more complex games with multiple variables, the trajectory may be less accurate.

Can the trajectory equation be applied to all types of games?

Yes, the trajectory equation can be applied to most types of games that involve objects in motion. However, it may need to be adapted or modified depending on the specific mechanics and variables of the game.

Back
Top