generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Bullet Drop Calculation (I forgot)

Previous Thread :: Next Thread 
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
06 Jun 2015 12:14 PM
it was something like
print(math.sqrt(velocity) + HeightFromGround * Gravity)
I think... I can't remember... anyone plz help me?
I know for sure there was math.sqrt and them 3 numbers (Velocity, Height, Gravity)

"My Life is going Good... but..."
Report Abuse
Fortixs is not online. Fortixs
Joined: 15 Dec 2008
Total Posts: 3967
06 Jun 2015 12:17 PM
Alright, you need the initial vertical velocity and vertical gravity.

Gravity is acceleration, so v = a * t + initalV
t would be the amount of time the bullet has been flying.
v would be the new vertical velocity.
Report Abuse
Fortixs is not online. Fortixs
Joined: 15 Dec 2008
Total Posts: 3967
06 Jun 2015 12:18 PM
And a would represent gravity, which I forget to note in the equation.
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
06 Jun 2015 12:21 PM
em, no, I mean if it's going STRAIGHT out, no resistance on the Y Axis :P

"My Life is going Good... but..."
Report Abuse
Fortixs is not online. Fortixs
Joined: 15 Dec 2008
Total Posts: 3967
06 Jun 2015 12:23 PM
v = a * t + initalV

This equation would still apply. :P

Except that the initalV would be 0: v = a * t
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
06 Jun 2015 12:26 PM
i dont get this math stuff
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
06 Jun 2015 12:35 PM
lol abstract XD

fort, no...
u say 'Time' is in the equation, but I don't know the time -_-
the equation I used before (which was accurate) was something to do with, Velocity, Gravity and HeightFromGround :P
so basically am shooting straight, the gun is like 4 Studs from the ground, and just shoot... that's the type of bullet drop I want, not those other one (cos the assume the Projectile starts from the ground)

"My Life is going Good... but..."
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
06 Jun 2015 12:36 PM
btw, sry, I forgot to say, that it's the Distance Travelled I wanted XD

"My Life is going Good... but..."
Report Abuse
Fortixs is not online. Fortixs
Joined: 15 Dec 2008
Total Posts: 3967
06 Jun 2015 12:41 PM
Oh, I thought when you said straight you meant straight down... but still you would use my original equation, which is derived using calculus (don't worry, I know what I'm doing).

You can calculate the time easily by adding the change in time from inital to final.

local initTime = time() --initial time

--bullet is shot
while true do
local finalTime = time() --final time is the current time
local deltaTime = finalTime - initialTime

--use deltaTime here in the equation I provided.

wait()

end
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
06 Jun 2015 12:44 PM
no, I wanna calculate the Distance on the spot like I used to :/
cos ya see, I don't like (in fact hate) testing a thing when am developing it (in a way of "Act before thinking", I like to "Think before I Act") if ya know what I mean...

"My Life is going Good... but..."
Report Abuse
Fortixs is not online. Fortixs
Joined: 15 Dec 2008
Total Posts: 3967
06 Jun 2015 12:45 PM
I'm assuming you're using a body velocity for the projectile, so get the inital y component of the velocity and then set its current velocity using its horizontal velocity and the final y component of the velocity which my equation calculates.
Report Abuse
ColdSmoke is not online. ColdSmoke
Joined: 02 Jan 2012
Total Posts: 5784
06 Jun 2015 12:46 PM
you can't calculate bullet drop accurately without time?
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
06 Jun 2015 12:46 PM
You have to calculate how long time ticks.
Report Abuse
Fortixs is not online. Fortixs
Joined: 15 Dec 2008
Total Posts: 3967
06 Jun 2015 12:48 PM
The distance traveled can be calculated by finding the change in position, which is the final position minus the inital position. In Roblox, position is a vector3, so the inital position is where you fire the bullet. Then using the 3d distance formula you can get the distance traveled...

local initPos
local finalPos

local dist = math.sqrt(math.pow(finalPos.x - initPos.x, 2) + math.pow(finalPos.y - initPos.y, 2) + math.pow(finalPos.z - initPos.z, 2))
Report Abuse
Fortixs is not online. Fortixs
Joined: 15 Dec 2008
Total Posts: 3967
06 Jun 2015 12:49 PM
You need time to calculate bullet drop unless there is a body acceleration, which Roblox doesn't have.
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
06 Jun 2015 12:49 PM
em, no, as I said, the gun is perfectly straight and is shooting straight (0 degrees) like this ---> and I don't use Body Movers

Cold, em, the calculation I had I could calculate Distance Travelled accurately :P

"My Life is going Good... but..."
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
06 Jun 2015 12:50 PM
now there we go :D I'll try test this thnx

"My Life is going Good... but..."
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
06 Jun 2015 12:52 PM
wait... is finalPos like where am aiming or something? o.O

"My Life is going Good... but..."
Report Abuse
Fortixs is not online. Fortixs
Joined: 15 Dec 2008
Total Posts: 3967
06 Jun 2015 12:52 PM
If you're not using body velocity or anything like that, then what are you using, it's position only?

Then you must take the derivative of the position to get velocity:

velocity = the change in position / the change in time

I shown you how to calculate the change in time and the change in position.
Report Abuse
Fortixs is not online. Fortixs
Joined: 15 Dec 2008
Total Posts: 3967
06 Jun 2015 12:53 PM
The final position is the position it is currently at as it moves. It is in a while loop when it is traveling, so the final position is changing.
Report Abuse
Fortixs is not online. Fortixs
Joined: 15 Dec 2008
Total Posts: 3967
06 Jun 2015 12:54 PM
I'm pretty sure there are no easier ways to do this than what I've just explained unless someone literally did it all for you.
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
06 Jun 2015 12:56 PM
actually, as I said, I had a calculation formula for accurate distance :P
all I had to do was just use HeightFromGround, Gravity, Velocity...
I just forgot the formula... I didn't even have to hit 'Play'!

"My Life is going Good... but..."
Report Abuse
Fortixs is not online. Fortixs
Joined: 15 Dec 2008
Total Posts: 3967
06 Jun 2015 01:02 PM
Lol, I'm pretty sure you don't understand what I'm trying to say... you still need to use my equation: v = a * t + initV

And I'm fairly certain you can't do anything with acceleration unless it involves time...


Hmm... Actually you could use a body force: F = ma --> Where m is the mass of the object and a is gravity.
Report Abuse
Fortixs is not online. Fortixs
Joined: 15 Dec 2008
Total Posts: 3967
06 Jun 2015 01:04 PM
You said:

cos ya see, I don't like (in fact hate) testing a thing when am developing it (in a way of "Act before thinking", I like to "Think before I Act") if ya know what I mean...

I just forgot the formula... I didn't even have to hit 'Play'!


So you're saying that my method doesn't involve thinking before acting? It's going to work no matter what you do before you even press play: that's why there are these equations. No testing is necessary.
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
06 Jun 2015 01:06 PM
"before you even press play"
but I thought u said the endPos is where the Projectile is now or something -_-
and then why would I use a loop when not testing it?

"My Life is going Good... but..."
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image