There are some places where there are rivers and lakes, and the game is the same. No matter for what purpose, the game of the people are also invisible ranked, so the role of each game position has been fastidious. So, there is the question of today: when everyone is a person of identity, how to move the most to reflect this status?
In fact, this problem is due to recent projects. Game type is a kind of RTS, but also need trooped walk, so there is a need: the whole team to move according to formation and smooth process.
Use Higo today to talk about this topic!
Higo is like driving a train, the locomotive walks naturally with the carriage, and the carriage does not scramble in the course of the walk, so it fits our demand model. Not around the circle, come down and say a few ways to achieve it.
1. The position of the other carriages is calculated by the front of the vehicle as the origin point.
This method should be a more common one, that is, after determining the position and angle of the front, along the opposite side through the compartment to determine the target location of each compartment. After you have identified the position, you can move the compartment to the target position and adjust the direction in the game, or let the compartment smooth toward the target point and change the compartment angle in real time.
Benefits: Simple calculation! In a two-dimensional space, knowing the direction of a point and point, it is easy to calculate a point at a reverse fixed interval. And the model's understanding cost is low, the realization is also simple.
The downside: It doesn't meet the demand at all! Has anyone seen a compartment teleport? The train is a straight line, the front of the car once the turn, the whole train to the front for the original point of rotation, visually give a person to kill the program impulse. Even if the carriage is moving smoothly, there is no guarantee that the rear end of the car can be connected to the head and tail, not to mention the possibility of staggered carriages when the turn is large. So under the current demand, this situation is pass.
2. Take each compartment back to a fixed point as the target point of the next carriage.
This method is the first variant that exists in order to crack the stiffness. The specific operation is to let the front of the car fixed a point as the target point of 1, and then after the car 1 coordinates and direction and then fixed a point as the car 2 of the target point, and so on. The advantage of doing this naturally does not make the train always a straight line, with the front turning, the compartment 1 moves to the target point and produces its own rotation, due to the superposition effect of rotation, the subsequent carriages naturally make the whole train into an arc. In this case, the teleport will also have a good effect, compared to the scenario 1 avoids the majority of the superposition situation. A smooth transition is better if it behaves naturally.
The Advantage: The train is finally no longer stiff, because each car's rotation is calculated from the previous compartment, so the resulting result itself is smoother and already close to demand.
Disadvantage: The calculation is aggravated, if the compartment is a little more, every time you need to calculate the direction of the car is a performance point of consumption. Although the movement is smoother, in the transient mode, because the rotation is superimposed, so the direction of rotation changes, the end of the car will have a larger distance displacement, resulting in distortion, still not suitable for the current demand.
3. The target points are calculated according to the distance between each compartment for the moving direction of the rear compartment.
This method is reversed in Method 2. The specific operation is the front movement, and then the car 1 to the front of the movement, and to ensure that the car 1 and the front of the distance is equal to the original interval, and then the carriage 2 to move after the carriage 1 move, and ensure that the distance is unchanged, and so on. In this case, we can calculate that as long as one side of the instantaneous rotation of the angle does not exceed the threshold, it can be guaranteed to be non-distorted (the threshold calculation and interval, instantaneous movement distance and direction, that is, to ensure that a moves with B after the interval is greater than a move and b before the interval).
Benefits: closest to current needs. The movement is no longer stiff, which solves the possible distortion of the left and right rotating moments, even with the use of a momentary shift to smooth the visual effect.
Disadvantage: The calculation of the method 2 is basically consistent, if the train model to explain the problem, the car between the connection between the dislocation of the distortion, but this distortion is much smaller than before.
A little summary.
At present, there are three kinds of attempts, and there are other schemes, such as recording the running trajectory and then recovering the frame. Overall, the above three kinds of trains such as the end-to-end requirements of the model, there will be distortion, but if it is only the track of the train operation, the scheme 3 more smoothly meet the requirements, Scheme 2, due to the speed of operation, the direction of rotation and other conditions of use is more stringent, plan 1 is thrown into the garbage bin. However, it is important to note that scenario 1, which is the least computationally-based scenario, is very much in a game of multi-character formations like the small corps. Only in the case of less people, for the sake of visual comfort, we dish exploration program 2, 3 this kind of program.
Secondly, the above three kinds of schemes for the progressive mode, there is a possibility of distortion. Once the rotation angle is too large and the movement speed is not enough, the overlap in the movement of the characters becomes unavoidable. Therefore, on the basis of the above-mentioned schemes, some other designs are needed to ensure the realism of the characters ' movement.
So how do I achieve this in my project?
The existing projects are basically based on programme 3. But for our project, Scenario 3 is just the first tier. The first thing to be clear is that our formation is not a mere Higo, but a variety of formations, but the basic goal is to make the protagonist move forward and turn in accordance with the formation. So we've applied scenario 3 as a basic model of formation. On top of Scenario 3, we nest formations in. For example, our "double vertical array" is the main character in two rows to move. In this case, we create a N/2 node according to the idea of scenario 3, and then put each of the 2 points in the formation into 1 nodes. Thus, when the nodes move, each point calculates the final position of the point based on the position and angle of the owning node and a fixed offset, and then moves smoothly toward the final position.
In-game formation movement analysis