| 12-26-2006, 07:45 PM | #1 |
if you are familiar with "meat hook" from pudge in the game "dota" then that looks somewhat like this ability except it doesn't hook and drag but spins and slashes instead. so far i have it so that it extends and curves like i want but my trouble is moving them at that same angle around the hero and staying in formation.. they go screwy at weird angles every time i test with different numbers. Here is how it looks after it extends.. extending only 10 units max starting from the facing angle of the casting unit. ![]() Then i want them to stay in that formation and spin around the hero.. like a weed-eater/wacker string. I use GUI and dont know JASS. so far i have the actions in my trig set up this formation already perfectly.. my trouble is spinning them around at the correct angles around the hero and have them also face the correct angle based on where they are. essentially what i'm saying is how do i mirror those black arrows to the other side or any side of that hero. what i've alread tried is setting a for each integer A 1-10 loop set var real angle = facing of the ArrowUnit [integer a] + x x being.. different numbers i've tried.. i've tried 45.. i've tried 35.. 25.. it never looks right. then i have it move each ArrowUnit [integer a] to the position of itself offset by 80 towards that real var angle i set.. then i have it face that same angle. am i on the right track and just need to keep testing til i get the right number or do i have to go a totally different route .. like using some math to get this right? |
| 12-26-2006, 09:47 PM | #2 |
Both position and direction transform like vectors under coordinate transformations. Write them in the coordinate system where the hero is at the origin: {x,y} Multiply by the rotation matrix {{cos(t),-sin(t)},{sin(t),cos(t)}} = {x cos(t)-y sin(t),x sin(t) + y cos(t)} if {x,y} = {cos(a),sin(a)} for you directions then you rewrite it as {cos(a) cos(t) - sin(a) sin(t), cos(a) sin(t) + sin(a) cos(t)} which is just {cos(a+t),sin(a+t)} So all you need to do is add the extra rotation angle in to your set facing angle. Note that mirroring is a different operation from rotation-it changes the handedness of the curve. At the moment it curves the way your right hand does, if you hold your screen to the monitor with thumb pointing towards you-mirroring will make it left handed. You can get this transformation by multiplying by the matrix {{-1,0},{0,1}}, which simply means x-> -x JASS:function Rotate2Vector takes location v, real angle returns nothing local real x = GetLocationX(v) local real y = GetLocationY(v) local real cos = Cos(angle) local real sin = Sin(angle) call MoveLocation(v, x*cos-y*sin,x*sin+y*cos) endfunction function RotateFacingAngle takes real facing, real angle returns real return facing + angle endfunction |
| 12-28-2006, 10:30 AM | #4 |
thx both of you have given me some ideas. pipedreams math + jass is a bit scarey. after i posted i got to thinking of a code that is somewhat similar to your gui you posted there, rulerofiron99. i had decided to stop telling the units to move to a tradrectory based off angles of themselves and base it off the caster since it's a easily known.. and since i suck so much at math. instead i decided that since i already was able to draw out the formation with the trigger that I would just have to make a Real Var distance with an array size of 10 mark ten distances to the caster from their each units current position in formation to the caster.... one per created unit and this would be marked only once and all spin motions would refer to it and never rewrite it during. This way it would force each unit to never go any further than that distance and never any closer either.. and had the caster facing angle set to "angle var", then each time the trigger ran it would "angle var" = to "angle var" + 2.. and had a loop integer A loop for 10 and tell created unit [integer a] to move to the position of the casting unit offset by that Real Var distance [integer a] that was first recorded... towards the "angle var" which would be 2 degress more around the unit and their own facing angles were based off the previous dummy units facing angle with a slight degree addition. such as the facing off the first chain link unit. anyhow, I managed to get it! i can't believe how smooth it is too. i thought it would be choppy but it's silk. if you want to see the result, check my map out. i released it to test that spell online for server splits and so far none showed up with that spell. Click Here To Download i dont bother to protect my map. feel free to use what you want. i dont mind. maybe you could look at it in action and look at the code and tell me if i left a leak or missed something that would make it cleaner yet.. if that's possible. i worked for 2 days on that spell. lol. play it and pick "Scorpion" hero (red-faced raider in furthest bottom-left tavern). tell me what you think. |
| 12-28-2006, 08:51 PM | #5 |
Sounds cool, comment cominhg soon. EDIT: very nice map, just make the spinning hook go a bit slower :P |
| 12-28-2006, 10:18 PM | #6 |
why slower? for aesthetic reasons or is there a prob having it run so often? |
| 12-28-2006, 11:35 PM | #7 |
I've got bad eyesight ![]() |
| 12-31-2006, 05:51 PM | #8 | |
Quote:
I still think PipeDream's math works way better just think of it as a triangle with the points moving...then you use cos,sin,and tan to figure out where the next point would be...then again this refers to your education level in math...seeming that PipeDream is a mathematician or he is just really good in trigonometry..this way would prove to be more effective...although the GUI way does work, too. |
