This content has been marked as final. Show 4 replies
I'm not sure if I understand. Do you just need to know why you are multiplying the speed or is there something that isn't working?
The multiplication is easy. Basically you have some speed, let's say 5. Now if you are going perfectly to the right along the x axis then you have 5 in the x direction and you have 0 in the y direction.
If you are going down the screen you have 5 in the y direction and 0 in the x direction. Easy.
But what if you are going at some angle? That is when it gets a little more tricky. Well back to your lovely unit circle. If you speed was 1 we have the same issue for the x and y directions. But if you go off at an angle you've got your sin component in the x direction and your cos in the y direction. And there you go, cos(0) = 1 and sin(0) = 0 meaning at an angle of zero all your motion is in the x direction.
So for a given angle cos shows the amount you've got in the x direction and sin shows the y direction. That way you can tell your object how many x and y to move and it looks like movement in at an angle. You multiply them because you aren't always using a unit circle.
Thank you very much for your reply,
So I am correct in saying that we multiply the speed to change the radius of the unit circle(as you said it isn't always a unit).In other words, are we just increasing the hypotenuse of the right triangle inside the circle?
EDIT: Or are we just making the _x and _y co-ordinates increase more according to our speed
Well I think both are just different ways of saying the same thing.
The unit circle, and its associated "unit triangle," will tell you the components of your velocity (velocity has a direction, speed doesn't) for a velocity of 1.
So you are increasing the hypotenuse of the right triangle, but it isn't inside a unit circle anymore! :)
And there is the principle of similar triangles. If we take a triangle and keep the angles the same the lengths of the sides will keep the same proportions.
So if the velocity is seven and we take the same unit triangle (all unit triangles have a hypotenuse of 1, right?) and then with the same angle we increase the hypotenuse to our new velocity, say 7, the x and y components (the other sides of the triangle) will both also be multiplied by 7.
Or alternately you are resolving a velocity vector into its orthonormal basis vectors. Just to muddy the waters. This is a fairly common mathematical problem that many people have resolved in a lot of different ways -- all related all with a little something different.
I've been trying to understand this for quite a while now and.............
I've finally UNDERSTOOD IT!
Now to get to the collision detection part for my car racing track which is another problem as flash only recognizes the boundary of my movie clip track. So no hitTest will work.