I was wondering if anyone could point me in the right way of how to do what I want to do. I never really understood the multiplayer concept. If I want a person to spawn at a specific point and he's a certain player how would I handle that? Also I want the camera to have it so everyone is within view, kind of like how a fighting game is stuck at a fixed position but if both players move right the camera will move right.
I'm not sure about the both players moving right making the camera move right, but keeping 2 points constantly fixated on player A and B, and using the distance between points function, should allow you to adjust your camera accordingly on a central point between the 2 players. For example, if player A is at 0, 100 and player B is at 100, 200 on the map (x, y respectively), the distance would be 141 from the distance formula w/ a slope of 1(I highly recommend keeping slope in terms of one decimal, such as .1 over 1/10, 2.3 over 23/10, and you will see why later). Using this you could then set a third point as an adjustment of 2 points, based on which x and y are greater or less, we will say less for this example, so (0, 100), Player A's point. Obviously, you will want this point to be a distance of 70.5 (141 / 2), scaling the x and y according to the slope. To do this, to the X coordinate we would add squareroot((Distance^2) / (1 + slope^2) which translates to squareroot((70.5^2) / (1 + 1^2) which comes up to about 49.8 to X, and for the Y coordinate we would add (DeltaX * Slope) which translates to (49.8 * 1) which obviously comes up to 49.8. Making our new point 49.8, 149.8 to center the camera around.
If you are curious where I pulled these numbers from, just use pythagorean theorum, you know the a^2 + b^2 = d^2, and of course the slope formula (y1-y2)/(x1-y2). All you have to do then is realize that (x1 - x2) = a = deltaX.
As far as the level of zoom to give the camera, I would just use the distance directly to come up with a zoom system you are happy with. I do apologize for not knowing the exact SC2 syntax for all this, I am still fairly new to its specific uses, but I am pretty confident doing that would solve the trace camera problem. It might also cover your both move right problem as well now that I think of it.
Imagine 3 players would make this idea a good deal more complicated, but not too terrible. Perhaps find the midpoint between A and B, A and C, and B and C, then take the average of the 3? Feel free to ask me any clarifying questions about the logic up top, I attempted to make it clear, but realize it may have been a fail, lol.
EDIT: Upon further thinking about this, don't worry about the complicated formula for the midpoint, just take the average in the first place of the 2 points, same result and a lot simpler math. You will still want the distance to decide how far to zoom though.
Thanks for the reply. I asked for two reasons, one for practicing some simple logic in starcraft 2 editor and the second reason is I was also curious of the logic for trying it out in UDK which you not using starcraft editor terms makes it easier to test it out for UDK and I can easily try it out in sc2 editor. Thanks.
Not a problem at all, logic I tend to do pretty good with, syntax is another story.... To aide in your messing around, I can verify that taking the average of all the midpoints between all players would work to set the ideal camera position. In fact, you could just feed your whatever number midpoints into an array, and run them through a loop to save on how many lines you might have, it could turn into a LOT of lines for 8 players, lol, 56 for finding the midpoints, 56-112 for adding them up, and 1-2 for finding the averages. Uh yea, use a loop!
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I was wondering if anyone could point me in the right way of how to do what I want to do. I never really understood the multiplayer concept. If I want a person to spawn at a specific point and he's a certain player how would I handle that? Also I want the camera to have it so everyone is within view, kind of like how a fighting game is stuck at a fixed position but if both players move right the camera will move right.
I'm not sure about the both players moving right making the camera move right, but keeping 2 points constantly fixated on player A and B, and using the distance between points function, should allow you to adjust your camera accordingly on a central point between the 2 players. For example, if player A is at 0, 100 and player B is at 100, 200 on the map (x, y respectively), the distance would be 141 from the distance formula w/ a slope of 1(I highly recommend keeping slope in terms of one decimal, such as .1 over 1/10, 2.3 over 23/10, and you will see why later). Using this you could then set a third point as an adjustment of 2 points, based on which x and y are greater or less, we will say less for this example, so (0, 100), Player A's point. Obviously, you will want this point to be a distance of 70.5 (141 / 2), scaling the x and y according to the slope. To do this, to the X coordinate we would add squareroot((Distance^2) / (1 + slope^2) which translates to squareroot((70.5^2) / (1 + 1^2) which comes up to about 49.8 to X, and for the Y coordinate we would add (DeltaX * Slope) which translates to (49.8 * 1) which obviously comes up to 49.8. Making our new point 49.8, 149.8 to center the camera around.
If you are curious where I pulled these numbers from, just use pythagorean theorum, you know the a^2 + b^2 = d^2, and of course the slope formula (y1-y2)/(x1-y2). All you have to do then is realize that (x1 - x2) = a = deltaX.
As far as the level of zoom to give the camera, I would just use the distance directly to come up with a zoom system you are happy with. I do apologize for not knowing the exact SC2 syntax for all this, I am still fairly new to its specific uses, but I am pretty confident doing that would solve the trace camera problem. It might also cover your both move right problem as well now that I think of it.
Imagine 3 players would make this idea a good deal more complicated, but not too terrible. Perhaps find the midpoint between A and B, A and C, and B and C, then take the average of the 3? Feel free to ask me any clarifying questions about the logic up top, I attempted to make it clear, but realize it may have been a fail, lol.
EDIT: Upon further thinking about this, don't worry about the complicated formula for the midpoint, just take the average in the first place of the 2 points, same result and a lot simpler math. You will still want the distance to decide how far to zoom though.
@Deadzergling: Go
Thanks for the reply. I asked for two reasons, one for practicing some simple logic in starcraft 2 editor and the second reason is I was also curious of the logic for trying it out in UDK which you not using starcraft editor terms makes it easier to test it out for UDK and I can easily try it out in sc2 editor. Thanks.
@Keyeszx: Go
Not a problem at all, logic I tend to do pretty good with, syntax is another story.... To aide in your messing around, I can verify that taking the average of all the midpoints between all players would work to set the ideal camera position. In fact, you could just feed your whatever number midpoints into an array, and run them through a loop to save on how many lines you might have, it could turn into a LOT of lines for 8 players, lol, 56 for finding the midpoints, 56-112 for adding them up, and 1-2 for finding the averages. Uh yea, use a loop!