<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ivan Zhukov</title>
    <description>The latest articles on DEV Community by Ivan Zhukov (@varlab).</description>
    <link>https://dev.to/varlab</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1160035%2F68d963b4-1b31-4b46-831c-13e4194805da.jpg</url>
      <title>DEV Community: Ivan Zhukov</title>
      <link>https://dev.to/varlab</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/varlab"/>
    <language>en</language>
    <item>
      <title>React + Three.js. Creating your own 3D shooter. Part 1</title>
      <dc:creator>Ivan Zhukov</dc:creator>
      <pubDate>Mon, 02 Oct 2023 09:27:39 +0000</pubDate>
      <link>https://dev.to/varlab/react-threejs-creating-your-own-3d-shooter-part-1-3ee2</link>
      <guid>https://dev.to/varlab/react-threejs-creating-your-own-3d-shooter-part-1-3ee2</guid>
      <description>&lt;p&gt;Hello, esteemed &lt;strong&gt;Dev.to&lt;/strong&gt; contributors!&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;In modern web development, the boundaries between classic and web applications are blurring every day. Today we can create not only interactive websites, but also full-fledged games right in the browser. One of the tools that makes this possible is the &lt;a href="https://docs.pmnd.rs/react-three-fiber/getting-started/introduction"&gt;&lt;strong&gt;React Three Fiber&lt;/strong&gt;&lt;/a&gt; library - a powerful tool for creating 3D graphics based on &lt;a href="https://threejs.org/"&gt;&lt;strong&gt;Three.js&lt;/strong&gt;&lt;/a&gt; using &lt;strong&gt;React&lt;/strong&gt; technology.&lt;/p&gt;

&lt;h3&gt;
  
  
  About the React Three Fiber stack
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;React Three Fiber&lt;/strong&gt; is a wrapper over &lt;strong&gt;Three.js&lt;/strong&gt; that uses the structure and principles of &lt;strong&gt;React&lt;/strong&gt; to create 3D graphics on the web. This stack allows developers to combine the power of &lt;strong&gt;Three.js&lt;/strong&gt; with the convenience and flexibility of &lt;strong&gt;React&lt;/strong&gt;, making the process of creating an application more intuitive and organised.&lt;/p&gt;

&lt;p&gt;At the heart of &lt;strong&gt;React Three Fiber&lt;/strong&gt; is the idea that everything you create in a scene is a &lt;strong&gt;React&lt;/strong&gt; component. This allows developers to apply familiar patterns and methodologies.&lt;/p&gt;

&lt;p&gt;One of the main advantages of &lt;strong&gt;React Three Fiber&lt;/strong&gt; is its ease of integration with the &lt;strong&gt;React&lt;/strong&gt; ecosystem. Any other &lt;strong&gt;React&lt;/strong&gt; tools can still be easily integrated when using this library.&lt;/p&gt;

&lt;h3&gt;
  
  
  Relevance of Web-GameDev
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Web-GameDev&lt;/strong&gt; has undergone major changes in recent years, evolving from simple 2D &lt;a href="https://www.adobe.com/products/flashplayer/end-of-life.html"&gt;&lt;strong&gt;Flash&lt;/strong&gt;&lt;/a&gt; games to complex 3D projects comparable to desktop applications. This growth in popularity and capabilities makes Web-GameDev an area that cannot be ignored.&lt;/p&gt;

&lt;p&gt;One of the main advantages of web gaming is its accessibility. Players do not need to download and install any additional software - just click on the link in their browser. This simplifies the distribution and promotion of games, making them available to a wide audience around the world.&lt;/p&gt;

&lt;p&gt;Finally, web game development can be a great way for developers to try their hand at gamedev using familiar technologies. Thanks to the available tools and libraries, even without experience in 3D graphics, it is possible to create interesting and high-quality projects!&lt;/p&gt;

&lt;h3&gt;
  
  
  Game performance in modern browsers
&lt;/h3&gt;

&lt;p&gt;Modern browsers have come a long way, evolving from fairly simple web browsing tools to powerful platforms for running complex applications and games. Major browsers such as &lt;strong&gt;Chrome&lt;/strong&gt;, &lt;strong&gt;Firefox&lt;/strong&gt;, &lt;strong&gt;Edge&lt;/strong&gt; and &lt;strong&gt;others&lt;/strong&gt; are constantly being optimised and developed to ensure high performance, making them an ideal platform for developing complex applications.&lt;/p&gt;

&lt;p&gt;One of the key tools that has fuelled the development of browser-based gaming is &lt;strong&gt;&lt;a href="https://www.khronos.org/webgl/"&gt;WebGL&lt;/a&gt;&lt;/strong&gt;. This standard allowed developers to use hardware graphics acceleration, which significantly improved the performance of 3D games. Together with other webAPIs, &lt;strong&gt;WebGL&lt;/strong&gt; opens up new possibilities for creating impressive web applications directly in the browser.&lt;/p&gt;

&lt;p&gt;Nevertheless, when developing games for the browser, it is crucial to consider various performance aspects: resource optimisation, memory management and adaptation for different devices are all key points that can affect the success of a project.&lt;/p&gt;

&lt;h3&gt;
  
  
  On your mark!
&lt;/h3&gt;

&lt;p&gt;However, words and theory are one thing, but practical experience is quite another. To really understand and appreciate the full potential of web game development, the best way is to immerse yourself in the development process. Therefore, as an example of successful web game development, we will create our own game. This process will allow us to learn key aspects of development, face real problems and find solutions to them, and see how powerful and flexible a web game development platform can be.&lt;/p&gt;

&lt;p&gt;In a series of articles, we'll look at how to create a first-person shooter using the features of this library, and dive into the exciting world of web-gamedev!&lt;/p&gt;

&lt;p&gt;Final demo&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;a href="https://zy45x4-5173.csb.app/" rel="noopener noreferrer"&gt;
      zy45x4-5173.csb.app
    &lt;/a&gt;
&lt;/div&gt;



&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;a href="https://codesandbox.io/p/github/JI0PATA/fps-game" rel="noopener noreferrer"&gt;
      codesandbox.io
    &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;Repository on &lt;a href="https://github.com/JI0PATA/fps-game"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let's get started!&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up the project and installing packages
&lt;/h3&gt;

&lt;p&gt;First of all, we will need a &lt;strong&gt;React&lt;/strong&gt; project template. So let's start by installing it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm create vite@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;select the &lt;strong&gt;React&lt;/strong&gt; library;&lt;/li&gt;
&lt;li&gt;select &lt;strong&gt;JavaScript&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Install additional npm packages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install three @react-three/fiber @react-three/drei @react three/rapier zustand @tweenjs/tween.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then &lt;a href="https://github.com/JI0PATA/fps-game/commit/4b55195e929d877d9231f35442e66346675522ed"&gt;delete&lt;/a&gt; everything unnecessary from our project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/4b55195e929d877d9231f35442e66346675522ed"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Customising the Canvas display
&lt;/h3&gt;

&lt;p&gt;In the &lt;strong&gt;main.jsx&lt;/strong&gt; file, add a div element that will be displayed on the page as a scope. Insert a &lt;strong&gt;Canvas&lt;/strong&gt; component and set the field of view of the camera. Inside the &lt;strong&gt;Canvas&lt;/strong&gt; component place the &lt;strong&gt;App&lt;/strong&gt; component.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bgJwoWQg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/af5dv55y0znz8jmmibjb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bgJwoWQg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/af5dv55y0znz8jmmibjb.png" alt="main.jsx" width="523" height="315"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's add styles to &lt;strong&gt;index.css&lt;/strong&gt; to stretch the UI elements to the full height of the screen and display the scope as a circle in the centre of the screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Urj38-F6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fa2fbpb28txcmfknjbae.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Urj38-F6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fa2fbpb28txcmfknjbae.png" alt="index.css" width="398" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;App&lt;/strong&gt; component we add a &lt;strong&gt;Sky&lt;/strong&gt; component, which will be displayed as the background in our game scene in the form of a sky.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ShFmJHOX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b7oymow8jvhyur3zc3cl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ShFmJHOX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b7oymow8jvhyur3zc3cl.png" alt="App.jsx" width="387" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZGe2UTEe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zs1horl7todkb6tsb349.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZGe2UTEe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zs1horl7todkb6tsb349.png" alt="Displaying the sky in the scene" width="800" height="387"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/ede1b9eb617c1967aef2f09104c234a87b68bc97"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Floor surface
&lt;/h3&gt;

&lt;p&gt;Let's create a &lt;strong&gt;Ground&lt;/strong&gt; component and place it in the &lt;strong&gt;App&lt;/strong&gt; component.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0DYzKyhy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/91resnjp955boszma2ek.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0DYzKyhy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/91resnjp955boszma2ek.png" alt="App.jsx" width="442" height="358"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;Ground&lt;/strong&gt;, create a flat surface element. On the Y axis move it downwards so that this plane is in the field of view of the camera. And also flip the plane on the X axis to make it horizontal.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Kb3h3kkR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r74p5xdafhge3uuoalsh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Kb3h3kkR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r74p5xdafhge3uuoalsh.png" alt="Ground.jsx" width="484" height="165"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Even though we specified grey as the material colour, the plane appears completely black.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uYhSlaAT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/apxdbsjygopgnwd5s84k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uYhSlaAT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/apxdbsjygopgnwd5s84k.png" alt="Flat on the scene" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/e9335eb32868ba48874b7461a6d79609a074f78b"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Basic lighting
&lt;/h3&gt;

&lt;p&gt;By default, there is no lighting in the scene, so let's add a light source &lt;strong&gt;ambientLight&lt;/strong&gt;, which illuminates the object from all sides and does not have a directed beam. As a parameter set the intensity of the glow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bSxljTj5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iia0azth2sac4c79klcz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bSxljTj5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iia0azth2sac4c79klcz.png" alt="App.jsx" width="434" height="138"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Yb1P2Khb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/81f0epirwf92oug0uaf2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Yb1P2Khb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/81f0epirwf92oug0uaf2.png" alt="Illuminated plane" width="800" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/385825283562b117c4b849c0c71832e0d634ec3e"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Texture for the floor surface
&lt;/h3&gt;

&lt;p&gt;To make the floor surface not look homogeneous, we will add texture. Make a pattern of the floor surface in the form of cells repeating all along the surface.&lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;assets&lt;/strong&gt; folder add a PNG image with a texture.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ENG2sKky--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wyeuitkz0fik5tt1ku2s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ENG2sKky--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wyeuitkz0fik5tt1ku2s.png" alt="Added texture" width="800" height="618"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To load a texture on the scene, let's use the &lt;strong&gt;useTexture&lt;/strong&gt; hook from the &lt;strong&gt;@react-three/drei&lt;/strong&gt; package. And as a parameter for the hook we will pass the texture image imported into the file. Set the repetition of the image in the horizontal axes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U9OIFCFJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/argjoo4zdfoh7akd4za0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U9OIFCFJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/argjoo4zdfoh7akd4za0.png" alt="Ground.jsx" width="686" height="318"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oUzar8-6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9w82g34cvjrvg9b1ema.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oUzar8-6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9w82g34cvjrvg9b1ema.png" alt="Texture on a plane" width="800" height="588"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/f1c91e9106b77f6c45b5edb48e3b229ba0e1862c"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Camera movement
&lt;/h3&gt;

&lt;p&gt;Using the &lt;strong&gt;PointerLockControls&lt;/strong&gt; component from the &lt;strong&gt;@react-three/drei&lt;/strong&gt; package, fix the cursor on the screen so that it does not move when you move the mouse, but changes the position of the camera on the scene.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SGiFrwsr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f8sg99r1utikbstgevyj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SGiFrwsr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f8sg99r1utikbstgevyj.png" alt="App.jsx" width="512" height="219"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GliLuWVs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/viu0qdds1b8ub7ic01aj.GIF" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GliLuWVs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/viu0qdds1b8ub7ic01aj.GIF" alt="Camera motion demonstration" width="500" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's make a small edit for the &lt;strong&gt;Ground&lt;/strong&gt; component.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9UTVseo---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jxxetaxfhpxe07lp1bek.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9UTVseo---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jxxetaxfhpxe07lp1bek.png" alt="Ground.jsx" width="688" height="160"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/3eb9816f82157b88647d185ec57bb7f9de959f62"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding physics
&lt;/h3&gt;

&lt;p&gt;For clarity, let's add a simple cube to the scene.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;mesh position={[0, 3, -5]}&amp;gt;
    &amp;lt;boxGeometry /&amp;gt;
&amp;lt;/mesh&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--L8FEDkBs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/utc8c2w3t6h7p0elof5d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--L8FEDkBs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/utc8c2w3t6h7p0elof5d.png" alt="The cube on the scene" width="800" height="579"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Right now he's just hanging in space.&lt;/p&gt;

&lt;p&gt;Use the &lt;strong&gt;Physics&lt;/strong&gt; component from the &lt;strong&gt;@react-three/rapier&lt;/strong&gt; package to add "physics" to the scene. As a parameter, configure the gravity field, where we set the gravitational forces along the axes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Physics gravity={[0, -20, 0]}&amp;gt;
    &amp;lt;Ground /&amp;gt;
    &amp;lt;mesh position={[0, 3, -5]}&amp;gt;
        &amp;lt;boxGeometry /&amp;gt;
    &amp;lt;/mesh&amp;gt;
&amp;lt;/Physics&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, our cube is inside the physics component, but nothing happens to it. To make the cube behave like a real physical object, we need to wrap it in the &lt;strong&gt;RigidBody&lt;/strong&gt; component from the &lt;strong&gt;@react-three/rapier&lt;/strong&gt; package.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RFm8OTqF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/97me24qefdpd5ya50ynh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RFm8OTqF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/97me24qefdpd5ya50ynh.png" alt="App.jsx" width="528" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that, we will immediately see that every time the page reloads, the cube falls down under the influence of gravity.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yeHNBIDX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6qvcgzdl2ivz208j3eyz.GIF" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yeHNBIDX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6qvcgzdl2ivz208j3eyz.GIF" alt="Сube fall" width="500" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But now there is another task - it is necessary to make the floor an object with which the cube can interact, and beyond which it will not fall.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/1f564e9836554b644d43dd75d4644aa9cd5159b1"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The floor as a physical object
&lt;/h3&gt;

&lt;p&gt;Let's go back to the &lt;strong&gt;Ground&lt;/strong&gt; component and add a &lt;strong&gt;RigidBody&lt;/strong&gt; component as a wrapper over the floor surface.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---_q_rNpg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bqz1c4ojczl8h55bkgr2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---_q_rNpg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bqz1c4ojczl8h55bkgr2.png" alt="Ground.jsx" width="721" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now when falling, the cube stays on the floor like a real physical object.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eRC4cQ49--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tkhr8m1kpqvsir6yw3n0.GIF" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eRC4cQ49--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tkhr8m1kpqvsir6yw3n0.GIF" alt="Falling cube on a plane" width="500" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/31fe05543209c6828b7d5b69f06189e9f48a124a"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Subjecting a character to the laws of physics
&lt;/h3&gt;

&lt;p&gt;Let's create a &lt;strong&gt;Player&lt;/strong&gt; component that will control the character on the scene.&lt;/p&gt;

&lt;p&gt;The character is the same physical object as the added cube, so it must interact with the floor surface as well as the cube on the scene. That's why we add the &lt;strong&gt;RigidBody&lt;/strong&gt; component. And let's make the character in the form of a capsule.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iIZLqx0l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r85p8ksnoxa1edpgfecc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iIZLqx0l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r85p8ksnoxa1edpgfecc.png" alt="Player.jsx" width="441" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Place the &lt;strong&gt;Player&lt;/strong&gt; component inside the Physics component.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ah4SuYXA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zst8lzm76kacng5zuu6g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ah4SuYXA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zst8lzm76kacng5zuu6g.png" alt="App.jsx" width="504" height="307"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now our character has appeared on the scene.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---J936XV9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/56duyjbc3vsb1ichuf6e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---J936XV9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/56duyjbc3vsb1ichuf6e.png" alt="A character in capsule form" width="800" height="515"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/8877590a4767a281e71b0d0e4d04e49ad4660773"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Moving a character - creating a hook
&lt;/h3&gt;

&lt;p&gt;The character will be controlled using the &lt;strong&gt;WASD&lt;/strong&gt; keys, and jump using the &lt;strong&gt;Spacebar&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;With our own react-hook, we implement the logic of moving the character.&lt;/p&gt;

&lt;p&gt;Let's create a &lt;strong&gt;hooks.js&lt;/strong&gt; file and add a new &lt;strong&gt;usePersonControls&lt;/strong&gt; function there.&lt;/p&gt;

&lt;p&gt;Let's define an object in the format {"keycode": "action to be performed"}. Next, add event handlers for pressing and releasing keyboard keys. When the handlers are triggered, we will determine the current actions being performed and update their active state. As a final result, the hook will return an object in the format {"action in progress": "status"}.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XtZWp_Bu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5yhdyiqoxlqhmnz1h2cj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XtZWp_Bu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5yhdyiqoxlqhmnz1h2cj.png" alt="hooks.js" width="516" height="914"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/4e83142bdd6e843e7bc6f434801d3a0817d0cd4e"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Moving a character - implementing a hook
&lt;/h3&gt;

&lt;p&gt;After implementing the &lt;strong&gt;usePersonControls&lt;/strong&gt; hook, it should be used when controlling the character. In the &lt;strong&gt;Player&lt;/strong&gt; component we will add motion state tracking and update the vector of the character's movement direction. &lt;/p&gt;

&lt;p&gt;We will also define variables that will store the states of the movement directions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xwlGVFre--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/15kxned83tb1hfftr7xa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xwlGVFre--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/15kxned83tb1hfftr7xa.png" alt="Player.jsx" width="336" height="92"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To update the character's position, let's &lt;strong&gt;useFrame&lt;/strong&gt; provided by the &lt;strong&gt;@react-three/fiber&lt;/strong&gt; package. This hook works similarly to &lt;strong&gt;requestAnimationFrame&lt;/strong&gt; and executes the body of the function about 60 times per second.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GFOYrmHX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1cs4qtvhnxeklduwco9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GFOYrmHX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1cs4qtvhnxeklduwco9.png" alt="Player.jsx" width="717" height="695"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Code Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. const playerRef = useRef();&lt;/strong&gt;&lt;br&gt;
Create a link for the player object. This link will allow direct interaction with the player object on the scene.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. const { forward, backward, left, right, jump } = usePersonControls();&lt;/strong&gt;&lt;br&gt;
When a hook is used, an object with boolean values indicating which control buttons are currently pressed by the player is returned.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. useFrame((state) =&amp;gt; { ... });&lt;/strong&gt;&lt;br&gt;
The hook is called on each frame of the animation. Inside this hook, the player's position and linear velocity are updated. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. if (!playerRef.current) return;&lt;/strong&gt;&lt;br&gt;
Checks for the presence of a player object. If there is no player object, the function will stop execution to avoid errors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. const velocity = playerRef.current.linvel();&lt;/strong&gt;&lt;br&gt;
Get the current linear velocity of the player.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. frontVector.set(0, 0, backward - forward);&lt;/strong&gt;&lt;br&gt;
Set the forward/backward motion vector based on the pressed buttons.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. sideVector.set(left - right, 0, 0);&lt;/strong&gt;&lt;br&gt;
Set the left/right movement vector.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. direction.subVectors(frontVector, sideVector).normalize().multiplyScalar(MOVE_SPEED);&lt;/strong&gt;&lt;br&gt;
Calculate the final vector of player movement by subtracting the movement vectors, normalising the result (so that the vector length is 1) and multiplying by the movement speed constant.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. playerRef.current.wakeUp();&lt;/strong&gt;&lt;br&gt;
"Wakes up" the player object to make sure it reacts to changes. If you don't use this method, after some time the object will "sleep" and will not react to position changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10. playerRef.current.setLinvel({ x: direction.x, y: velocity.y, z: direction.z });&lt;/strong&gt;&lt;br&gt;
Set the player's new linear velocity based on the calculated direction of movement and keep the current vertical velocity (so as not to affect jumps or falls).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As a result, when pressing the &lt;strong&gt;WASD&lt;/strong&gt; keys, the character started moving around the scene. He can also interact with the cube, because they are both physical objects.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--waZ1SJjR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i2r9xnyr5dwgcc4mz3hr.GIF" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--waZ1SJjR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i2r9xnyr5dwgcc4mz3hr.GIF" alt="Character movement" width="500" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/e385028ce949545cf58ade19dfdb8250643498d1"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Moving a character - jump
&lt;/h3&gt;

&lt;p&gt;In order to implement the jump, let's use the functionality from the &lt;strong&gt;@dimforge/rapier3d-compat&lt;/strong&gt; and &lt;strong&gt;@react-three/rapier&lt;/strong&gt; packages. In this example, let's check that the character is on the ground and the jump key has been pressed. In this case, we set the character's direction and acceleration force on the Y-axis.&lt;/p&gt;

&lt;p&gt;For &lt;strong&gt;Player&lt;/strong&gt; we will add mass and block rotation on all axes, so that he will not fall over in different directions when colliding with other objects on the scene.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RAcdZPta--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y7q28cyh7g2kpn8dsoca.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RAcdZPta--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y7q28cyh7g2kpn8dsoca.png" alt="Player.jsx" width="800" height="891"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Code Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;const world = rapier.world;&lt;/strong&gt;&lt;br&gt;
Gaining access to the &lt;strong&gt;Rapier&lt;/strong&gt; physics engine scene. It contains all physical objects and manages their interaction.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;const ray = world.castRay(new RAPIER.Ray(playerRef.current.translation(), { x: 0, y: -1, z: 0 }));&lt;/strong&gt;&lt;br&gt;
This is where "raycasting" (raycasting) takes place. A ray is created that starts at the player's current position and points down the y-axis. This ray is "cast" into the scene to determine if it intersects with any object in the scene.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;const grounded = ray &amp;amp;&amp;amp; ray.collider &amp;amp;&amp;amp; Math.abs(ray.toi) &amp;lt;= 1.5;&lt;/strong&gt;&lt;br&gt;
The condition is checked if the player is on the ground:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ray&lt;/strong&gt; - whether the &lt;strong&gt;ray&lt;/strong&gt; was created;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ray.collider&lt;/strong&gt; - whether the ray collided with any object on the scene;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Math.abs(ray.toi)&lt;/strong&gt; - the "exposure time" of the ray. If this value is less than or equal to the given value, it may indicate that the player is close enough to the surface to be considered "on the ground".&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;You also need to modify the &lt;strong&gt;Ground&lt;/strong&gt; component so that the raytraced algorithm for determining the "landing" status works correctly, by adding a physical object that will interact with other objects in the scene.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--G71c4GrR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dfrbafl83k7q6hushbzq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--G71c4GrR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dfrbafl83k7q6hushbzq.png" alt="Ground.jsx" width="716" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's raise the camera a little higher for a better view of the scene.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C5rbwnCm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8d6zzpvj5pg6egn4jznf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C5rbwnCm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8d6zzpvj5pg6egn4jznf.png" alt="main.jsx" width="516" height="161"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ndDRB59D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sikur9w4q0khyovyubht.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ndDRB59D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sikur9w4q0khyovyubht.gif" alt="Character jumps" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Section code&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/bc2c22d9661defb4e645fac17e63457505604ac9"&gt;First commit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/f5bad070b78677e9924fc4599a2025baf7dffb09"&gt;Second commit&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Moving the camera behind the character
&lt;/h3&gt;

&lt;p&gt;To move the camera, we will get the current position of the player and change the position of the camera every time the frame is refreshed. And for the character to move exactly along the trajectory, where the camera is directed, we need to add &lt;strong&gt;applyEuler&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5hFlZIai--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1pakhpm7os9ye48u8cmn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5hFlZIai--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1pakhpm7os9ye48u8cmn.png" alt="Player.jsx" width="800" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Code Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;applyEuler&lt;/strong&gt; method applies rotation to a vector based on specified Euler angles. In this case, the camera rotation is applied to the &lt;strong&gt;direction&lt;/strong&gt; vector. This is used to match the motion relative to the camera orientation, so that the player moves in the direction the camera is rotated.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's slightly adjust the size of &lt;strong&gt;Player&lt;/strong&gt; and make it taller relative to the cube, increasing the size of &lt;strong&gt;CapsuleCollider&lt;/strong&gt; and fixing the "jump" logic.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Sx7LHmAB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zipboc3ag69g88oy77z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Sx7LHmAB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zipboc3ag69g88oy77z.png" alt="Player.jsx" width="800" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WAoDHROw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gbkureuddexfj9w9gui0.GIF" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WAoDHROw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gbkureuddexfj9w9gui0.GIF" alt="Moving the camera" width="500" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Section code&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/74e2206a9d16d78268224d9d451cd2405ec162ab"&gt;First commit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/0063ea91b5981e7ce2be89b71d73a9f2d69a624a"&gt;Second commit&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Generation of cubes
&lt;/h3&gt;

&lt;p&gt;To make the scene not feel completely empty, let's add cube generation. In the json file, list the coordinates of each of the cubes and then display them on the scene. To do this, create a file &lt;strong&gt;cubes.json&lt;/strong&gt;, in which we will list an array of coordinates.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
  [0, 0, -7],
  [2, 0, -7],
  [4, 0, -7],
  [6, 0, -7],
  [8, 0, -7],
  [10, 0, -7]
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the &lt;strong&gt;Cube.jsx&lt;/strong&gt; file, create a &lt;strong&gt;Cubes&lt;/strong&gt; component, which will generate cubes in a loop. And &lt;strong&gt;Cube&lt;/strong&gt; component will be directly generated object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import {RigidBody} from "@react-three/rapier";
import cubes from "./cubes.json";

export const Cubes = () =&amp;gt; {
    return cubes.map((coords, index) =&amp;gt; &amp;lt;Cube key={index} position={coords} /&amp;gt;);
}

const Cube = (props) =&amp;gt; {
    return (
        &amp;lt;RigidBody {...props}&amp;gt;
            &amp;lt;mesh castShadow receiveShadow&amp;gt;
                &amp;lt;meshStandardMaterial color="white" /&amp;gt;
                &amp;lt;boxGeometry /&amp;gt;
            &amp;lt;/mesh&amp;gt;
        &amp;lt;/RigidBody&amp;gt;
    );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's add the created &lt;strong&gt;Cubes&lt;/strong&gt; component to the &lt;strong&gt;App&lt;/strong&gt; component by deleting the previous single cube.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--u5nCVGz8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gkucql8nt043k79u0x6y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u5nCVGz8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gkucql8nt043k79u0x6y.png" alt="App.jsx" width="506" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9BG_y4_0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ug92paizn2kmlh754hqx.GIF" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9BG_y4_0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ug92paizn2kmlh754hqx.GIF" alt="Generation of cubes" width="500" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/357405aab1cf8f49699397c7bcf07fa9ca7b667d"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Importing the model into the project
&lt;/h3&gt;

&lt;p&gt;Now let's add a 3D model to the scene. Let's add a weapon model for the character. Let's start by looking for a 3D model. For example, let's take &lt;a href="https://sketchfab.com/3d-models/low-poly-aks-74u-4aa2f92e016c434eafdba67b238bb7fb"&gt;this one&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Download the model in GLTF format and unpack the archive in the root of the project.&lt;/p&gt;

&lt;p&gt;In order to get the format we need to import the model into the scene, we will need to install the &lt;strong&gt;gltf-pipeline&lt;/strong&gt; add-on package.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm i -D gltf-pipeline&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Using the &lt;strong&gt;gltf-pipeline&lt;/strong&gt; package, reconvert the model from the &lt;strong&gt;GLTF format&lt;/strong&gt; to the &lt;strong&gt;GLB format&lt;/strong&gt;, since in this format all model data are placed in one file. As an output directory for the generated file we specify the &lt;strong&gt;public&lt;/strong&gt; folder.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gltf-pipeline -i weapon/scene.gltf -o public/weapon.glb&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then we need to generate a react component that will contain the markup of this model to add it to the scene. Let's use the &lt;a href="https://gltf.pmnd.rs/"&gt;official resource&lt;/a&gt; from the &lt;strong&gt;@react-three/fiber&lt;/strong&gt; developers. &lt;/p&gt;

&lt;p&gt;Going to the converter will require you to load the converted &lt;strong&gt;weapon.glb&lt;/strong&gt; file.&lt;/p&gt;

&lt;p&gt;Using drag and drop or Explorer search, find this file and download it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2AdF-mCm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nv5t3y6yjbfeyv6w0n50.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2AdF-mCm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nv5t3y6yjbfeyv6w0n50.png" alt="Converted model" width="800" height="843"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the converter we will see the generated react-component, the code of which we will transfer to our project in a new file &lt;strong&gt;WeaponModel.jsx&lt;/strong&gt;, changing the name of the component to the same name as the file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/0621b9ac3ab267dbc94a99264662d9d896f80207"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Displaying the weapon model on the scene
&lt;/h3&gt;

&lt;p&gt;Now let's import the created model to the scene. In &lt;strong&gt;App.jsx&lt;/strong&gt; file add &lt;strong&gt;WeaponModel&lt;/strong&gt; component.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HPAoRFdh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7cvpf5s9ol9tz8aw14sm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HPAoRFdh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7cvpf5s9ol9tz8aw14sm.png" alt="App.jsx" width="428" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6KhvaF6b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9xbtai5v514f3tlzb399.GIF" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6KhvaF6b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9xbtai5v514f3tlzb399.GIF" alt="Demonstration of the imported model" width="500" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/2f3aae04743b0f87724c723bb68ad71e5cbca53b"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding shadows
&lt;/h3&gt;

&lt;p&gt;At this point in our scene, none of the objects are casting shadows.&lt;/p&gt;

&lt;p&gt;To enable &lt;strong&gt;shadows&lt;/strong&gt; on the scene you need to add the &lt;strong&gt;shadows&lt;/strong&gt; attribute to the &lt;strong&gt;Canvas&lt;/strong&gt; component.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qURxZ3q3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/93kzaek3ltusj2go7rxw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qURxZ3q3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/93kzaek3ltusj2go7rxw.png" alt="main.jsx" width="415" height="160"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we need to add a new light source. Despite the fact that we already have &lt;strong&gt;ambientLight&lt;/strong&gt; on the scene, it cannot create shadows for objects, because it does not have a directional light beam. So let's add a new light source called &lt;strong&gt;directionalLight&lt;/strong&gt; and configure it. The attribute to enable the "&lt;strong&gt;cast&lt;/strong&gt;" shadow mode is &lt;strong&gt;castShadow&lt;/strong&gt;. It is the addition of this parameter that indicates that this object can cast a shadow on other objects.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cW7Pe7BV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/song3on9si3dphyf1gbz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cW7Pe7BV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/song3on9si3dphyf1gbz.png" alt="App.jsx" width="421" height="358"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that, let's add another attribute &lt;strong&gt;receiveShadow&lt;/strong&gt; to the &lt;strong&gt;Ground&lt;/strong&gt; component, which means that the component in the scene can receive and display shadows on itself.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--on1gFd8s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r3mnka27xcvo35kxjmc5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--on1gFd8s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r3mnka27xcvo35kxjmc5.png" alt="Ground.jsx" width="715" height="162"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ENzsUCgA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bumyixdxkktuj3ogi5jq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ENzsUCgA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bumyixdxkktuj3ogi5jq.png" alt="The model casts a shadow" width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similar attributes should be added to other objects on the scene: cubes and player. For the cubes we will add &lt;strong&gt;castShadow&lt;/strong&gt; and &lt;strong&gt;receiveShadow&lt;/strong&gt;, because they can both cast and receive shadows, and for the player we will add only &lt;strong&gt;castShadow&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Let's add &lt;strong&gt;castShadow&lt;/strong&gt; for &lt;strong&gt;Player&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4hQ6upKR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fywdqz11egxglrg5pszf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4hQ6upKR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fywdqz11egxglrg5pszf.png" alt="Player.jsx" width="640" height="158"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add &lt;strong&gt;castShadow&lt;/strong&gt; and &lt;strong&gt;receiveShadow&lt;/strong&gt; for &lt;strong&gt;Cube&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Hix4PX1w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zj8eebfo3v0xckgyy9n9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Hix4PX1w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zj8eebfo3v0xckgyy9n9.png" alt="Cube.jsx" width="471" height="159"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZlIiPqxY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ppf8la65kvo5ictvi4p6.GIF" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZlIiPqxY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ppf8la65kvo5ictvi4p6.GIF" alt="All objects on scene cast a shadow" width="500" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/9a1c30993bf65f8dfdb7230f42d03c38d0682bb8"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding shadows - correcting shadow clipping
&lt;/h3&gt;

&lt;p&gt;If you look closely now, you will find that the surface area on which the shadow is cast is quite small. And when going beyond this area, the shadow is simply cut off.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Zrt0Df5P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wt1ta7e99d4m0rk8mn6e.GIF" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Zrt0Df5P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wt1ta7e99d4m0rk8mn6e.GIF" alt="Shadow cropping" width="500" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The reason for this is that by default the camera captures only a small area of the displayed shadows from &lt;strong&gt;directionalLight&lt;/strong&gt;. We can for the &lt;strong&gt;directionalLight&lt;/strong&gt; component by adding additional attributes &lt;strong&gt;shadow-camera-(top, bottom, left, right)&lt;/strong&gt; to expand this area of visibility. After adding these attributes, the shadow will become slightly blurred. To improve the quality, we will add the &lt;strong&gt;shadow-mapSize&lt;/strong&gt; attribute.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rs0BUvuO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i5a9aklj9aubo0or1zjh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rs0BUvuO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i5a9aklj9aubo0or1zjh.png" alt="App.jsx" width="479" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/6fb490223ef97707fa4c465ae478c5f415ee6661"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Binding weapons to a character
&lt;/h3&gt;

&lt;p&gt;Now let's add first-person weapon display. Create a new &lt;strong&gt;Weapon&lt;/strong&gt; component, which will contain the weapon behaviour logic and the 3D model itself.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import {WeaponModel} from "./WeaponModel.jsx";

export const Weapon = (props) =&amp;gt; {
    return (
        &amp;lt;group {...props}&amp;gt;
            &amp;lt;WeaponModel /&amp;gt;
        &amp;lt;/group&amp;gt;
    );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's place this component on the same level as the &lt;strong&gt;RigidBody&lt;/strong&gt; of the character and in the &lt;strong&gt;useFrame&lt;/strong&gt; hook we will set the position and rotation angle based on the position of the values from the camera.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RS9JmO57--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hiou1ztcl741rmrr8zxg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RS9JmO57--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hiou1ztcl741rmrr8zxg.png" alt="Player.jsx" width="800" height="737"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gAe3lEPF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t3l1bppukustl3nidurr.GIF" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gAe3lEPF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t3l1bppukustl3nidurr.GIF" alt="First-person weapon model display" width="500" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/fbe4dccdfe6de98e97aad043e7083b34f3a81a7f"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Animation of weapon swinging while walking
&lt;/h3&gt;

&lt;p&gt;To make the character's gait more natural, we will add a slight wiggle of the weapon while moving. To create the animation we will use the installed &lt;strong&gt;tween.js&lt;/strong&gt; library.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Weapon&lt;/strong&gt; component will be wrapped in a group tag so that you can add a reference to it via the &lt;strong&gt;useRef&lt;/strong&gt; hook.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eFjwNQ0O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9tnmhzahw7vrrqrga1uh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eFjwNQ0O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9tnmhzahw7vrrqrga1uh.png" alt="Player.jsx" width="605" height="122"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's add some &lt;strong&gt;useState&lt;/strong&gt; to save the animation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hasitObb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wambx1iyiv0gmkul1gvk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hasitObb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wambx1iyiv0gmkul1gvk.png" alt="Player.jsx" width="639" height="86"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's create a function to initialise the animation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zELw2tOf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7p7ju9or81nyoal7w58a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zELw2tOf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7p7ju9or81nyoal7w58a.png" alt="Player.jsx" width="551" height="582"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Code Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;const twSwayingAnimation = new TWEEN.Tween(currentPosition) ...&lt;/strong&gt;&lt;br&gt;
Creating an animation of an object "swinging" from its current position to a new position.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;const twSwayingBackAnimation = new TWEEN.Tween(currentPosition) ...&lt;/strong&gt;&lt;br&gt;
Creating an animation of the object returning back to its starting position after the first animation has completed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;twSwayingAnimation.chain(twSwayingBackAnimation);&lt;/strong&gt;&lt;br&gt;
Connecting two animations so that when the first animation completes, the second animation automatically starts.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;In &lt;strong&gt;useEffect&lt;/strong&gt; we call the animation initialisation function.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hiZYl5cE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xrtoz3can91dq14eti1c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hiZYl5cE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xrtoz3can91dq14eti1c.png" alt="Player.jsx" width="307" height="62"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now it is necessary to determine the moment during which the movement occurs. This can be done by determining the current vector of the character's direction.&lt;/p&gt;

&lt;p&gt;If character movement occurs, we will refresh the animation and run it again when finished.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vzyW9QFM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qxsimc6fva5co7fx9wit.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vzyW9QFM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qxsimc6fva5co7fx9wit.png" alt="Player.jsx" width="418" height="123"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Code Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;const isMoving = direction.length() &amp;gt; 0;&lt;/strong&gt;&lt;br&gt;
Here the object's movement state is&lt;br&gt;
checked. If the direction vector has a length greater than 0, it means that the object has a direction of movement.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;if (isMoving &amp;amp;&amp;amp; isSwayingAnimationFinished) { ... }&lt;/strong&gt;&lt;br&gt;
This state is executed if the object is moving and the "swinging" animation has finished.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;In the &lt;strong&gt;App&lt;/strong&gt; component, let's add a &lt;strong&gt;useFrame&lt;/strong&gt; where we will update the tween animation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GHXjp5sD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sc6du50vztex64ib227m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GHXjp5sD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sc6du50vztex64ib227m.png" alt="App.jsx" width="245" height="103"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TWEEN.update()&lt;/strong&gt; updates all active animations in the &lt;strong&gt;TWEEN.js&lt;/strong&gt; library. This method is called on each animation frame to ensure that all animations run smoothly.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Section code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/3e986e87f1daa1ed9e20fabc7675ca83142d1d78"&gt;First commit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/12abbcd9d5b922e8766b859ff82272de08099c06"&gt;Second commit&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Recoil animation
&lt;/h3&gt;

&lt;p&gt;We need to define the moment when a shot is fired - that is, when the mouse button is pressed. Let's add &lt;strong&gt;useState&lt;/strong&gt; to store this state, &lt;strong&gt;useRef&lt;/strong&gt; to store a reference to the weapon object, and two event handlers for pressing and releasing the mouse button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dzCiDbcI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/skxdt2hstku20qzlu28q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dzCiDbcI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/skxdt2hstku20qzlu28q.png" alt="Weapon.jsx" width="442" height="47"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5USEKoqq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l4ke7w98t944o8cbrp9d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5USEKoqq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l4ke7w98t944o8cbrp9d.png" alt="Weapon.jsx" width="433" height="184"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hRsGj8co--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jale7g9uhgfvs4e070bn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hRsGj8co--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jale7g9uhgfvs4e070bn.png" alt="Weapon.jsx" width="304" height="161"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's implement a recoil animation when clicking the mouse button. We will use &lt;strong&gt;tween.js&lt;/strong&gt; library for this purpose. &lt;/p&gt;

&lt;p&gt;Let us define constants for recoil force and animation duration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qaYz-_Tr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3lfvqnotkm1trdqo7bou.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qaYz-_Tr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3lfvqnotkm1trdqo7bou.png" alt="Weapon.jsx" width="341" height="69"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As with the weapon wiggle animation, we add two useState states for the recoil and return to home position animation and a state with the animation end status.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XKFCvsW_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/evye2ui2avcgvh7593xp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XKFCvsW_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/evye2ui2avcgvh7593xp.png" alt="Weapon.jsx" width="554" height="44"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's make functions to get a random vector of recoil animation - &lt;strong&gt;generateRecoilOffset&lt;/strong&gt; and &lt;strong&gt;generateNewPositionOfRecoil&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kS8B19BI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f8ks8c7gom330a8mv5fe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kS8B19BI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f8ks8c7gom330a8mv5fe.png" alt="Weapon.jsx" width="475" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create a function to initialise the recoil animation. We will also add &lt;strong&gt;useEffect&lt;/strong&gt;, in which we will specify the "shot" state as a dependency, so that at each shot the animation is initialised again and new end coordinates are generated.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bONDlF2c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q4in2uxi4pc5uwpbznqk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bONDlF2c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q4in2uxi4pc5uwpbznqk.png" alt="Weapon.jsx" width="558" height="481"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5XAvhOiH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tsaz6nmujwosiqp6yzig.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5XAvhOiH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tsaz6nmujwosiqp6yzig.png" alt="Weapon.jsx" width="292" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And in &lt;strong&gt;useFrame&lt;/strong&gt;, let's add a check for "holding" the mouse key for firing, so that the firing animation doesn't stop until the key is released.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OwOZJU_M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/doqiot4xls39ev8dvkub.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OwOZJU_M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/doqiot4xls39ev8dvkub.png" alt="Weapon.jsx" width="258" height="104"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rIZs87_L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/55sis3bksg5dwpvzg98c.GIF" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rIZs87_L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/55sis3bksg5dwpvzg98c.GIF" alt="Recoil animation" width="500" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JI0PATA/fps-game/commit/8a1a38b6402503d87b05dfc4d83834d5d9ed3a9c"&gt;Section code&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Animation during inactivity
&lt;/h3&gt;

&lt;p&gt;Realise the animation of "inactivity" for the character, so that there is no feeling of the game "hanging".&lt;/p&gt;

&lt;p&gt;To do this, let's add some new states via &lt;strong&gt;useState&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_zTy8Mz5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/de0xzc6agbaot1ucyo35.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_zTy8Mz5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/de0xzc6agbaot1ucyo35.png" alt="Player.jsx" width="746" height="63"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's fix the initialisation of the "wiggle" animation to use values from the state. The idea is that different states: walking or stopping, will use different values for the animation and each time the animation will be initialised first.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RRP0WbY2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ob0kqp07j7njou0rbbk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RRP0WbY2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ob0kqp07j7njou0rbbk.png" alt="Player.jsx" width="561" height="506"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AyGqKWJJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c7x9w2rq99mbx97d9na9.GIF" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AyGqKWJJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c7x9w2rq99mbx97d9na9.GIF" alt="Idle animation" width="500" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In this part we have implemented scene generation and character movement. We also added a weapon model, recoil animation when firing and at idle. In the next part we will continue to refine our game, adding new functionality.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>threejs</category>
      <category>r3f</category>
    </item>
  </channel>
</rss>
