Why does “character movement” seem simple, but requires extremely high technical skills and detailed costs?


“Character Movement”It is the basis of most games. But in the game, he looks so simple and natural that it is easy to be ignored by players.In fact, the movement of the character involvesAnimation, rendering, physics, synchronizationMany other development techniques and a lot of art work. Even in terms of design alone, “role movement” often brings developers into a dilemma. All in all, it is really difficult to perfect the character movement.

There is a wall-climbing animation in the Demo of Unreal 5 demo. It is not easy to make this effect.

This article will focus on the movement of 3D characters and talk about why such basic functions require extremely high technical skills and detailed costs.

1. Movement principle and common problems

I have talked about “the basic principles of game character movement” in a popular science article on the public account.
The game world is the same as the real world, and it is also a three-dimensional space (a 2D game is a two-dimensional space). All characters in our game will be born, move, interact and die in this three-dimensional world. In addition to characters, other objects in the game are also produced in this way, such as buildings, weapons, props, and so on. They all store their own coordinate positions. When we move our character, we are actually constantly modifying the coordinate value of the current character.

Jerish ——How do the characters in the game “move”?

So it is actually very simple to make an object move in the game world-Just change his position.

But if we control aHumanoid character, It’s not enough to simply modify his position, we also need to make the characterWalk more natural and real. In other words, it is to make the character’s movement look closer to the real world.This actually involvesHuman body structure, physical forceWaiting for a lot of complicated issues, it is difficult for us to passSimple mathematical model or physics engineTo achieve the desired effect.Therefore, the current game industry usually uses artificialAnimationWay to replace real physical simulation.

There are two ways to achieve animation: vertex animation and skeletal animation, which are now commonly usedSkeletal animationTo handle the movement of the character.Skeletal animation will abstract the 3D model into somekey pointThese key points are connected to each other to form a “skeleton” and form a complete skeleton structure. We can generate animation for the model by changing the orientation and position of the bones.

It can be seen that whether a character’s movements are natural or not depends largely on the design of the animator.

Now, with the position and animation, the character can really move.The movement of each character in the game needs to be maintained by two basic systems, one is for the characterAnimation system, The other is hidden behind the codeComputing system(Can be called a mobile component system). The character animation system is responsible for playing its animation according to the timestamp, which is generally produced by art through three-dimensional modeling software (2D is relatively simple, which is to replace pictures by frames, and 3D is generally skeletal animation). Import the animation into the game engine, you can see that the character will keep playing the moving animation, but he will not move forward.

So can the character move perfectly? No, the nightmare has just begun.The first to appear is a very commonBasic question-“Slide”, The root cause of sliding isThe performance in the animation does not match the movement distance of its actual position (the character walks 10 meters in a step, and it looks like it is sliding).

Solving slippage is usually considered from two aspects,

The first aspectIt is a regular movement for the character. Generally speaking, the speed of the player is regular in the process of walking and running, either at a constant speed or at a constant acceleration. At this time, the mobile component system can be applied, that is, whenever the player plays a moving animation, the player’s state is used to reasonably calculate and apply the displacement length it should walk. In this way, the role movement in the usual sense can be realized. In other words,These more regular mobile computing can be handed over to the code level to process, The code needs to carefully consider the state of the character and calculate the displacement through a reasonable mathematical model.

The second aspectIt is for more complicated special movements. If the character does not move at a uniform speed or at a uniform acceleration, our mobile component system can’t be calculated at all. Even if your code is well written, it is difficult to achieve the desired effect of art.therefore weRootmotion solutions are usually used, That is, the position of each frame is handed over to the art for processing. They also write the displacement information into the animation when making the animation. It is just fine to read the art data when we move.

Of course, considering the art workload and other issues, we can’t all use rootmotion to solve them.The role also has some special processing but more general state, such asTurn, turn around, stop suddenly, etc.,Obviously, the player’s body will lean when turning, and when turning around, our footsteps should be gradually stepped on. When suddenly stopping, there must be an effect of stopping the footsteps and recovering (rather than sliding directly).Use animation state machine with blending space (Blendspace: can be blended according to two input animations)Can solve most of the problems, but still need a lot of art production animation resources.

andstate machine, And the concept of the computer’s FSM (Finite State Machine) is similar. In the game, in fact, we pre-defined some nodes as character behavior states, such as running, standing, squatting, etc. When we press the squat button, we judge whether a certain state switching condition is met. If it is satisfied, the character will transfer from the default state to the squat state.

If you look closely, you will find that many previous games did not deal with these details because it was too cumbersome.

In recent years, one calledMotionMatchThe popular technology is used to solve the convergence problem of various animations. His basic principle is to first make a rich animation resource library, and then continuously select the most suitable animation for the next frame from the resource library according to the current character’s actions and state information when the character moves. Ubisoft’sFor Honor“This kind of technology is adopted, and theDeep learningTo choose the action, it achieved very good results. However, this technique is obviously not suitable for small teams. Perhaps after many years there will be a complete set of shared open source action libraries, and everyone can experience the convenience brought by this technology.

https://www.gdcvault.com/play/1023280/Motion-Matching-and-The-Road

Well, if we successfully solve the above problems, can we make the character move happily?

Of course the answer is NO!There are a bunch of advanced problems waiting for us to solve below, and different games face completely different situations!

Second, mobile advanced issues

1. collision

When a player starts to move, what should I do if he encounters an obstacle? Should he push the obstacle or be blocked? How are the standards set? If I hit another player, can I drive him away? Does the player go up the stairs level by level or level by level? How much slope can the player walk on? There are countless similar problems, and many of them are game design problems.

Most of these problems can be solved with the support of the physics engine and through radiographic testing, but there are also some situations that are difficult to handle.

For the above problems, here is a brief list of common solutions. Larger objects are set to be static (that is, they will not move), so the player will be blocked when they move, while the smaller objects can be stepped on directly. As for whether or not to push other players, it depends on the type of game. In order to keep the camera smooth when going up the stairs, we will set the physics of the steps to be smooth.

2. Special mode

I said so much just for the characters to walk, and the designer’s idea in the game is unconstrained, and the planning may want the charactersFlying, swimming, hanging single poles, climbing ladders, and various anti-physical behaviors that force Newton out of the coffin board (such as multi-jumping, light work)Wait, how do you deal with these mobile patterns?

In fact, each of the above special mobile methods requires special handling methods, and there is almost no unified solution. For example, when climbing a ladder, in order for the player’s hand to overlap with the handle of the ladder, we need to set the interval of the ladder strictly and adapt it to the animation. At the same time, it is also necessary to make a special movement mode, only when the character is in the state of climbing a ladder, the Z value of the coordinates can only be modified at a uniform speed.

In short, the special mode is very complicated, and each function is enough for programming and art.

The process of climbing the ladder in Neal Mechanical Age 2B is designed to be very comfortable

3. Special objects

The characters we control are not necessarily humanoid characters, but also cars and animals.

For the car object, one advantage is that we basically don’t need to consider the adaptation of the animation, because the car does not need to wave its limbs like a person, as long as the wheels move (of course, 3A-level racing games like Horizon and Need for Speed, The animation of the car body is also quite complicated). But we need to simulate the trajectory of its movement perfectly in the program, which must involve the use and optimization of the physics engine, and the difficulty is quite high.

For animals, we need to solve some bone processing problems. Because humanoid characters are widely used in games, the related system support is fairly good. But because the skeleton structure of animals is different from that of humans, we need to make new art resources, which means that human-shaped bone resources cannot be adapted to animals. If you make all kinds of creatures with very different structures, then the art will definitely be exhausted. (So, if you look closely, you will find that the body structures of many mobs in a game are similar)

4. Connection of multiple mobile states

As mentioned earlier, characters may walk, run, sing, jump, fly, swim, etc. How should you connect when you switch from one state to another? I was suddenly hit by a car while walking (a bit miserable). Should I land on my head or my bottom? Was it the animation of flying out at the moment of being hit? If you were shot while climbing a fence forward, should you fall forward or backward? How tall and thick can you climb over the wall?

Sometimes we can open the roleRagdoll (ragdoll system), which is completely handed over to the physics engine to process some mobile simulations. But in many cases, we want the player to be able to control the final effect, so we can’t give it to the physics engine. The current animation system of some engines supports physics-based animation. We can mix physics and animation according to fixed weights, which reduces the workload of art to a certain extent and can also achieve some more realistic effects.

5. Mobile sync

I have said so much before, but only for single-player games. If you are an online game, how do you tell other clients what to do when your character moves? What if the delay is too large and the positions or animations of the two clients are different? In many games, mobile synchronization is a considerable problem, because the player’s position may change every frame.

Common synchronization schemes are“Frame synchronization” (Lockstep) and “State synchronization”, There are also many optimized solutions. For specific details, please refer to my previous series of articles.

The development and changes of network synchronization in game history (1)-network synchronization and network architecture
The development and changes of network synchronization in game history (2)-Lockstep and frame synchronization
The development and changes of network synchronization in the game history (3)-the development process and principle of state synchronization (part 1)
The development and changes of network synchronization in the game history (4)-the development process and basic principles of state synchronization (part 2)

6. Other details

For example, can the level be left, and how to prevent the player from passing by? (AdoptableAir wallProcessing, but players hate air walls)

Can two people walk through a small space together?Because if one player is standing there, other players may have a bad experience, so you may considerAdjust the size of the colliderCome so that two people can pass side by side.Of course, this also involvesLevel design issues

What should I do if I wear the mold halfway? Adjust the animation or collision body.
There are many, many similar problems, and I will not list them all here.

Three, summary

In general, character movement is not simply related to a few systems. It can be said that it involves most of the design logic of the entire Gameplay. Even in some games, we think that he is the core of the gameplay.

However, in many cases, he appears so natural that many players ignore it.

Author: Jerish
Source: Those things about game development
Address: https://mp.weixin.qq.com/s/lvsmuyrQjffpW8N_P2i_yA

.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *