| 05-05-2009, 09:09 AM | #1 |
How do I get them? I have variable speed & knockback0 for knockback issues. I have velocityZ, positionZ and gravity for flying issues. Now lets say I want to knockback a unit 300 distance away and I want it to form a nice looknig curve using vectors with all those variables. Does anybody here has the formula or can teach me how to do so? Or at least an example. |
| 05-05-2009, 11:48 AM | #2 |
Why would a knockbacked unit move in a curve? |
| 05-05-2009, 12:45 PM | #3 |
JASS:
method projectToPoint takes real speed, real tx, real ty, real tz, real arc returns nothing
local real a = Atan2( ty - .y, tx - .x )
local real d = SquareRoot( ( tx - .x ) * ( tx - .x ) + ( ty - .y ) * ( ty - .y ) )
local real t = d / speed
set .gravity = -8*arc*speed*speed/d
set .xVel = speed * Cos( a )
set .yVel = speed * Sin( a )
set .zVel = (-.gravity) * t / 2 + ( tz - .z ) / t
call SetUnitAnimationByIndex( .self, R2I( bj_RADTODEG * Atan2( .zVel, SquareRoot( .xVel * .xVel + .yVel * .yVel ) ) + 0.5 ) + 90 )
endmethod
(This for projectile dummies, so you can remove animation thing ...) |
| 05-05-2009, 12:52 PM | #4 |
I don't understand some parts of it, why does it returns nothing when I need it? How much should the arc be? TX and TY is X & Y of the target guy who's flying right? What's T? |
| 05-05-2009, 07:28 PM | #5 |
It is what I use for projectile arcs -> It is 'method', part of struct It sets variables held by the struct, hence no return t = time .x and .y are assumed to be current position tx and ty are target position' the animation part can be removed, it was for a pitch dummy |
| 05-06-2009, 09:35 AM | #6 |
So it should return a real value right? What would the end result be? So every timeout, I should do this? SetUnitFlyHeight(whichUnit,.zVel,0) ? This isn't a ParabolaZ function too right? I need it to return the amount of vector needed to make a nice curve from location A to B. |
| 05-06-2009, 10:35 AM | #7 | |
Quote:
|
| 05-06-2009, 10:56 AM | #8 |
Well yeah it's ok. My physics chapter is still with the stuffs like distance, speed and time. No contact with vectors but I can always learn. Yeah, I googled them and to no avail. Could you mind explaining it in bigger terms to me although I might ask alot of questions. |
| 05-07-2009, 07:47 AM | #9 |
A vector in the usual 3D-space is just like an arrow with a direction and a length. Usually you handle them as a tuple of 3 reals, in vJass a vector could look like this: JASS:struct vector real x real y real z endstruct Then of course you can add two vectors, which is like putting the first arrow to the end of the second arrow. In jass you would do it like this: JASS:function add takes vector a, vector b returns vector local vector r = vector.create() set r.x = a.x + b.x set r.y = a.y + b.y set r.z = a.z + b.z return r endfunction The other important operation with vectors is multiplication witch a scalar value, which is like stretching the arrow. Do you now understand that there is nothing like the "amount of vector"? |
| 05-07-2009, 07:54 AM | #10 |
Yes +rep i got it solved sometime ago but +rep for effort. |
