# Naturalized Motion Generator for NPC in 3D Game

Jong-Chul Yoon, In Seob Yoon, Jong-Sung Hong

► To cite this version:

Jong-Chul Yoon, In Seob Yoon, Jong-Sung Hong. Naturalized Motion Generator for NPC in 3D Game. 16th International Conference on Entertainment Computing (ICEC), Sep 2017, Tsukuba City, Japan. pp.366-369, 10.1007/978-3-319-66715-7_41. hal-01771239

HAL Id: hal-01771239

https://inria.hal.science/hal-01771239v1

Submitted on 19 Apr 2018

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons CC BY 4.0 - Attribution - International License
# Naturalized motion generator for NPC in 3D game

Jong-Chul Yoon¹ In Seob Yoon²

and Jong-Sung Hong³

Dept. of Broadcasting Technology, Kangwon National University ¹,²,³

media19@kangwon.ac.kr ¹ isyoon@kangwon.ac.kr ² jshong@kangwon.ac.kr ³

**Abstract.** In the 3D game, there are many NPCs for various purposes, and the variety of motion of these NPCs increases the immersion feeling of the game. In this paper, we propose a noise-based motion editing technique that can add diversity and naturalness to the motion of NPCs. In the area of computer graphics, noise function has been used as a classical method of applying the naturalness of the animation. We extract these noise functions from existing motion signals and control them to make many similar motions naturally.

**Keywords:** Character animation, Noise function, Noise fitting

## 1. Introduction

The NPC in the game is widely used as a hint to help the game progress or as an element to increase the fun factor. Most of these NPCs take only simplified motions because of the limitation of production, and these limited motions act as an obstacle to the immersion feeling of the game. To solve this simplicity, we propose a technique for applying styles to npc movements. In order to generate stable motion without special attention of the game maker, we propose a technique to change the motion richly using the noise function which is a classical computer graphics element.

Since Perlin [1] introduced the noise function, it has been used in various computer graphics applications for adding random patterns to naive animations or to produce procedural textures. Using noise function, we extract motion pattern from existing motions as non-uniform hierarchical functions, which we can then apply to synthesize new motions with similar characteristics. Users can control the randomness at specified frequencies by varying the parameters of the noise function, while preserving the features of the motion pattern. The advantage of Perlin's classical noise function compared to the various noise functions for the recently introduced anti-aliasing enhanced rendering [2,3] is that Perlin noise is generated for a given random table. Since the motion of a each joint forms of a one-dimensional signal, it can be extracted as a sum of noise function and it is possible to generate a new motion with similar but diversity when the transformation is applied to the random table. Our system proposes a method to easily generate multiple similar motions using this noise function.
<figure><img src="image_2.png" /><figcaption>Figure 1. Motion signal fitting by multiple noise function: refining the extracted noise using a hierarchical noise function.</figcaption></figure>

## 2. Motion analysis based on the noise function.

To construct a noise function that represents the motion signal, we need to find the representative frequency of motion signal. We use the discrete Fourier transform (DFT) to derive the representative frequency. Because general motion signal has a various frequencies, we use method of statistical stability to extract representative frequency which was introduced by Dischler and Ghazanfarpour [4]. Let $fr$ be a representative frequency of given motion signal, then we can design the Perlin noise function as follows:

$$N(t) = Noise(f_r \cdot t), \qquad (1)$$

where, $t$ represent time parameter. Since our purpose is to represent the motion signal as a noise function, we need to fit a normalized motion signal is $S(t)$ to a noise function. We design the objective function which changes the random number table of the noise function newly and it to be as similar as possible to the given motion signal as follows:

$$\minimize \sum_{i=1}^{N} (S(t) - N(t))^2 \qquad (2)$$

The above optimization problem minimizes the squared difference between the noise value and the motion signal. We used the sequential equality constrained quadratic programming method [5] with the active-set technique [6] to solve the optimization problem.

As mentioned above, since the motion signal contains various frequencies, it is difficult to fit the entire motion signal with a noise function of a single frequency. So we have designed an iterative noise extraction algorithm which generates a function of pyramidal form. If we extract noise of a single frequency from motion signal that possibly includes frequencies outside that range, then fitting that single frequency noise may not match real motion signal particularly well. Nevertheless, a noise function obtained in this way will still approximate the input date to some extent, so
the resulting error value have lower amplitude than the original motion signal. Therefore we find representative frequency of error signal and than fit the noise interactively until the error is smaller than a given threshold; the result is in the form of a fractal sum. Using this mechanism, which we call the noise pyramid, we can extract motion signal for various frequencies (see Figure 1). The more octaves we use, the better the approximation that can be achieved.

### 3. Similar motion generation for NPC

To test our noise-based system, we selected a simple walking motion and a drunken motion and extracted the difference between the two motion as a noise pyramid. Since the noise function can generate random signals at infinite time, we can generate various similar motions with different time parameters. In an extended tome domain, the noise function repeatedly computes the similar patterns. This is because we preserve the statistical characteristics of the extracted pattern by retaining the distribution of random number table of noise function. Using this property, we simulate a crowd NPC motion by varying different frequencies. As shown Figure 2, each of the resulting images shows the four different variations of a single motion simultaneously that from a crowd.

<figure><img src="image_3.png" /><figcaption>Figure 2. Crowd simulation using time domain expansion: (a) is a base motion and (b) is the target motion for noise extraction. Using the hierarchical time domain expansion, we simulate a NPC crowd by controlling desired frequency terms (c). Each of these three images shows a crowd made by four different variations on the motion of a single character.</figcaption></figure>

Figure 3 shows another application called motion analogy; in which a motion is adapted to a specific style. The analogy factor, drunken style, is extracted as a non-uniform hierarchical noise function as the difference between a pair of inputs (normal walking, drunken walking) and then the style is applied to a 'dancing' motion. The result is a 'drunken dance' and it is possible to apply this style to various types of NPC motion generation.
<figure><img src="image_4.png" /><figcaption>Figure 3. Motion analogy: using the drunken motion pattern from Figure 2, we create a version of the pattern (the blue figure is performing the original motion and the red figure performs the adapted motion).</figcaption></figure>

## 4. Conclusions

We have introduced a system that extracts signal pattern from given motion signal and uses it to create various similar motion pattern using noise function. Our method allows the user to control the randomness of particular frequencies within the pattern, while preserving its appearance, and this cab generate the various but similar motion for NPC. Because noise function does not require complex calculation, our method has advantages of lower complexity and it can be used real-time application like 3D game. The limitation of this paper is that it is difficult for the user to control motion detail because the noise depends on the randomness. We will develop a user-friendly interface to compensate for this.

## Acknowledgements.

This research was supported by Basic Science Research Program through the National Research Foundation of Korea(NRF) funded by the Ministry of Education, Science and Technology (NRF-2017R1D1A3B03033656).

## References

1. Perlin K.: Realtime responsive animation with personality. IEEE Transactions on Visualization and Computer Graphics 1(1), 5–15. (1995)

2. Cook R. L., Derose T.: Wavelet noise. ACM Transactions on Graphics 24(3), 803–811, (2005)

3. Goldberg A., Zwicker M., Durand F: Anisotropic noise. ACM Transactions on Graphics 27(3),54:1–54:8, (2008)

4. Dischler J. M., Ghazanfarpour D.: A procedural description of geometric textures by spectral and spatial analysis of profiles. In Proceedings of EURO-GRAPHICS '97, pp. 129–139, (1997).

5. Spellucci P.: An sqp method for general non-linear programs using only equality constrained subproblems. Mathematical Programming 82, 413–448, (1998)

6. Fletcher R.: Practical Methods of Optimization. John Wiley and Sons, (1987)