<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[First Person View Cameras]]></title><description><![CDATA[<p dir="auto"> </p>
<h2><a class="anchor-offset" name="prerequisite"></a>Prerequisite</h2>
<ul>
<li><a href="/topic/37/the-follow-camera">The Follow Camera</a></li>
</ul>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="introduction"></a>Introduction</h2>
<p dir="auto">Many 3D games and demos let the user take a “first person view”, as if the user himself is walking inside the virtual world. The user can use the mouse to turn around and look at different parts of the world. You can easily create such an experience in CreatiCode.</p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="using-the-follow-camera-in-a-new-way"></a>Using the Follow Camera in A New Way</h2>
<p dir="auto">To create a “first person view”, you can actually reuse the <a href="/topic/37/the-follow-camera">follow camera</a>, but in a different way.</p>
<p dir="auto">Recall that to use the follow camera, you need to have a target object first, then you add the follow camera to follow that target. Here is a typical example:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/4f4b0348-2f7c-4fa2-8c08-aebf8b0290d7.png" width="1000" /></p>
<p dir="auto"> <br />
When you run this program, you can turn the camera to look at the avatar from different angles, so the user feels like he or she is not the avatar, but watching from behind the avatar.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/85337302-7d1c-4595-93f1-f37a5b812926.gif" width="500" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> <br />
<strong><span style="color:#ff0000">To look through the eyes of the avatar, we can simply move the camera to the position of the eyes of the avatar</span></strong>. To do that, we need to change the distance to 0 between the camera and the avatar. Also, if the avatar’s height is 100, we can assume the eyes are about 86 units from the ground, so we set the “z-offset” to 86 to make the camera stay at eye level.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/d0cb16bc-1e93-45b0-802d-30f7e7f0a1b5.png" width="660" /></p>
<p dir="auto"> <br />
Now if we run the project, our camera is indeed inside the avatar’s brain and looking behind the avatar’s eyes:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/054cb24b-0f14-407d-b73a-a1aa30e61314.gif" width="500" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> <br />
Of course, the avatar’s head is blocking our camera, so we can’t see anything else. To fix that, we just need to hide the avatar itself:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/18a592b7-33d7-4310-8bd8-b37873228c2f.png" width="500" /></p>
<p dir="auto"> <br />
Now we get a perfect first person view. As we turn the camera around with the mouse pointer, we are no longer looking at the avatar, but at the scene around us instead.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/088ad549-0b79-434b-b55c-15133d80418b.gif" width="500" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="use-a-transformer-instead-of-an-object"></a>Use a Transformer Instead of An Object</h2>
<p dir="auto">Instead of an object like an avatar or a car, you can also choose to use a transformer object. This is handy when your project will stay in the first person view all the time.</p>
<p dir="auto">Since a transformer object is not visible, you don’t need to hide it anymore, and it will load much faster than an avatar. However, you do need to move it to the correct height in the Z direction.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/29bccc02-05dc-4e95-b4a6-f0a0d0652856.png" width="900" /></p>
<p dir="auto"> <br />
You will get the same first-person view as the previous method.</p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="lock-the-mouse-pointer-to-the-camera"></a>Lock the Mouse Pointer to the Camera</h2>
<p dir="auto">In the program above, to turn the camera around, we have to press the mouse button and drag the pointer on the stage. However, sometimes we want to allow the user to use the mouse buttons for other types of interactions, such as picking or shooting.</p>
<p dir="auto">Therefore, we can “lock the mouse pointer”, so that the camera will turn as the user moves the mouse pointer without pressing down any mouse buttons.</p>
<p dir="auto">You can use the following block to lock or unlock the mouse pointer. Select “Yes” to lock and “No” to unlock.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/80a0413f-9426-418c-b458-040840c30b72.png" width="250" /></p>
<p dir="auto"> <br />
For example, let’s add it to the program from above:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/771ac19b-82de-4883-a62e-0c41c95c15ea.png" width="450" /></p>
<p dir="auto"> <br />
Now if you click the green flag button, the mouse will become locked: the pointer will be hidden, and the camera will turn as you move the mouse. Note that you can press the “ESC” key on the top left of the keyboard to unlock the pointer manually, and click anywhere on the stage to lock it again.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/b9cefec4-5fd7-4afa-b28a-3c4cde0cd489.gif" width="500" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="use-a-start-button-to-trigger-the-lock"></a>Use a “Start” Button to Trigger the Lock</h2>
<p dir="auto">It is often better to <a href="/topic/69/the-button-widget">use a button</a> to trigger the pointer lock. It will give the user an option to choose when to enter the locked mode, and also the pointer will be in the center of the stage when it enters the locked mode.</p>
<p dir="auto">Here is an example program. When the “Start” button is clicked, we first hide that button, then lock the pointer:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/c05a194b-ac96-49b7-be1f-926a1060c4e0.png" width="700" /></p>
<p dir="auto"> <br />
Now the mouse will only become locked after you click “Start”:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/dc562617-a845-45cb-b98e-ddd73acbc8f7.gif" width="500" style="border-radius:5px;border:1px solid #29622d" /></p>
]]></description><link>https://forum.creaticode.com/topic/599/first-person-view-cameras</link><generator>RSS for Node</generator><lastBuildDate>Sun, 09 Aug 2026 14:13:56 GMT</lastBuildDate><atom:link href="https://forum.creaticode.com/topic/599.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 11 Sep 2022 14:21:19 GMT</pubDate><ttl>60</ttl></channel></rss>