| 07-25-2009, 12:01 PM | #1 |
When I change the timeout of the knockback for velocity and acceleration parameters, distance of knockback seems to get longer which makes the timeout unconfigurable. Formula for distance is done by kinematics. When a user inputs velocity and acceleration, Here is some code simplified. JASS://Initialization //x and y are initial coordinates of target set d.distance = speed*speed/2/decrement set d.position = vector.create(x,y) set d.velocity = vector.create(Cos(angle),Sin(angle)) call d.velocity.setLength(speed) set d.acceleration = vector.create(d.velocity.x*-1,d.velocity.y*-1) call d.acceleration.setLength(decrement) call .velocity.velocity(.acceleration) // i know these names suck call .position.position(.velocity) call SetUnitX(.target,.position.x) call SetUnitY(.target,.position.y) JASS:method velocity takes vector a returns nothing set .x = .x + a.x set .y = .y + a.y endmethod method position takes vector a returns nothing set .x = .x + a.x * TIME set .y = .y + a.y * TIME endmethod |
| 07-25-2009, 01:15 PM | #2 | |
Quote:
Physics: v = v0 + a*t x = x0 + v*t |
| 07-25-2009, 01:47 PM | #3 |
Is that alright? the velocity vector has not been converted to the timeframe. I tested and it seems that it will take a long time for the unit to stop. |
| 07-25-2009, 01:51 PM | #4 |
v = v0 + 0.5*A*t x = x0 + v*t That's all. |
| 07-25-2009, 02:11 PM | #5 | ||
Quote:
Quote:
|
| 07-25-2009, 02:14 PM | #6 |
Finding time is sort of impossible. For example 800 initial velocity and -7 acceleration T = -vi/a 800/-7 = 114.28........ |
| 07-25-2009, 02:31 PM | #7 |
Uh what? You don't have to find time. You just need to use bigger (or if negative smaller) values for acceleration. Example: using the function you posted in the first post let's say you have a unit with an initial velocity v of 1000 and a constant negative acceleration (air resistance or whatever) of -10. Each time your method "velocity" is called that acceleration will be added to velocity, so it will take 100 function calls to make that unit stop IRREGARDLESS of how big TIME is. That means if TIME is 0.01 then it will take exactly 1 second to make the unit stop. But if you increase that value to 0.02 it will take 2 seconds which shouldn't be the case. using the correct function (same values as first example): Now it will take 10000 function calls to make the unit stop because TIME (= 0.01) is taken into consideration. But as that function is called every TIME seconds (I assume?) it will take a constant amount of time (= 100 seconds) to stop the unit irregardles of TIME. But as the time it takes to stop the unit is 100 times as big now you have to multiply the initial acceleration by factor 0.01. |
| 07-25-2009, 02:40 PM | #8 |
Yes it does works, now thanks alot but I want to ask about something. when JASS:method velocity takes vector a returns nothing set .x = .x + a.x * TIME // why do you multiply acceleration by the time period and not velocity too set .y = .y + a.y * TIME endmethod method position takes vector a returns nothing // you should name the taken vector "v" to not mess things up set .x = .x + a.x * TIME set .y = .y + a.y * TIME endmethod |
| 07-25-2009, 02:43 PM | #9 |
Because nature says: v = v0 + a*t x = x0 + v*t And you don't want to argue with nature do you? I'm sure you will lose. |
| 07-25-2009, 08:02 PM | #10 |
...the reason you're multiplying by time is because the input is in WC3 Units per second, and you're moving stuff on a timestep. So your Velocity must then be converted to "Wc3 Units per TIME". |
