| 10-22-2009, 01:39 AM | #1 |
Hey was wondering if someone could help me out once again :). I took Calculus, but I never got the chance to take Physics (Don't ask). So I don't really know any of the formulas, and was wondering if someone could explain one to me. Anyway if anyone has ever played like any of the Legend of Zelda games there is ice in the game. When you first walk on the ice, your movement is like slow and slippery. Eventually you start to glide and move faster. Then if you turn in the opposite direction you still glide in your previous direction and you move in the opposite direction in a slow slippery manner. Eventually you will start up and move in that direction. I was wondering if anyone knew how to re-create this and if they could help me with it, and explain it. (I would rather learn then someone say here just use this, but I understand if it takes too long to explain and am ok with a simple here take this). Sorry if my definitions are wrong, but I figured the further distance you click away from your unit the more force(think thats right word). So you would move farther with a farther click. If you clicked closer it would be less force and a smaller distance. |
| 10-22-2009, 02:01 AM | #2 |
This is sort of similar to what I was helping Zandose out with, where he's making a spaceship map. The essence of it is that the unit's movement has to be triggered using a timer to store some important values, then move the unit at a certain interval. Most of it can be explained through kinematics equations - that is, ones that deal with motion in one or more dimensions but don't rely on the sources of that motion. Essentially, you'll deal with three vectors: Position (x and y of the unit..., resolved into x and y components) Velocity (v) (Derivative of position in respect to time), or d(pos)/dt Acceleration (Derivative of velocity in respect to time) or dv/dt You need to have an initial velocity stored for when the unit hits the ice - lets say 300 warcraft units / second at the angle it is walking, this is arbitrary or can be averaged out by finding the average velocity between two points at the edge of the ice. When the unit slides on the ice, it experiences no net acceleration (because we assume that the surface is frictionless. If you want friction, then we need to use some mechanics as opposed to just kinematics). But when you change direction, you begin accelerating in that new direction, at a slow rate. You start adding the base acceleration times the timer interval to the velocity ( v + dv/dt * dt = v + dv = new V ). You add the new V to the position (in this case already at the right magnitude because you added the small acceleration already multiplied by the interval), pos + dv/dt * dt = pos + dv = new pos. How do you apply these values as vectors? Knowing the angle of movement (found by finding the angle between the unit point and the move target point), you can find each component of each vector by just multiplying the magnitude by the pertaining sine / cosine of each angle. Hope that makes sense. JASS:struct vector real x real y endstruct set acceleration.x = magnitude*Cos(theta) * TIMER_INTERVAL set acceleration.y = magnitude*Sin(theta) * TIMER_INTERVAL // ... set velocity.x = velocity.x + acceleration.x set velocity.y = velocity.y + acceleration.y set pos.x = pos.x (or GetUnitX()) + velocity.x set pos.y = pos.y (or GetUnitY()) + velocity.y |
| 10-22-2009, 02:52 AM | #3 |
Thank you I will try this out tomorrow, and I'm very excited too :). I read it, and seems like an easy understandable guide to my problem. +rep. |
