<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Wesley Campbell on Medium]]></title>
        <description><![CDATA[Stories by Wesley Campbell on Medium]]></description>
        <link>https://medium.com/@wesley.n.campbell?source=rss-8fc0b56566e4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*fFT1gLWdN3hOixOM</url>
            <title>Stories by Wesley Campbell on Medium</title>
            <link>https://medium.com/@wesley.n.campbell?source=rss-8fc0b56566e4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 20 May 2026 13:39:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wesley.n.campbell/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Window Layout for Animating Clips in Unity Using Timeline]]></title>
            <link>https://medium.com/@wesley.n.campbell/window-layout-for-animating-clips-in-unity-using-timeline-fc642889e5b7?source=rss-8fc0b56566e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc642889e5b7</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[timeline]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[learning]]></category>
            <dc:creator><![CDATA[Wesley Campbell]]></dc:creator>
            <pubDate>Wed, 17 Jan 2024 10:27:46 GMT</pubDate>
            <atom:updated>2024-01-17T10:27:46.233Z</atom:updated>
            <content:encoded><![CDATA[<p>When animating objects in Unity using Timeline, it can be a bit cumbersome to switch back and forth between various windows. Perhaps your Timeline or Animation windows are tabbed with your Game window so you can’t see the final shot. Maybe you have to switch between the Scene and Game windows to animate and then analyze the result.</p><p>I’ve found a setup that allows you to use both Scene and Game windows and keeps the Timeline and Animation windows separate. Let’s go over how to set this up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BmGK5BgvWqEN9T0J5-xh1w.jpeg" /></figure><h3>Setting Up the Timeline Layout</h3><p>It may be difficult to figure out how to create a window below multiple windows, so here’s how I set up this space.</p><p>First start with the 2 by 3 layout preset in the top right of Unity or a similar setup. Next, open the Timeline window by navigating to Window &gt; Sequencing &gt; Timeline, and dock the window at the bottom of one of the column windows to the right. Finally, you just need to combine the columns into one window and then separate them again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yDUJ43MWlCuld1VrphgJ_g.gif" /><figcaption>Setting Up the Timeline Layout</figcaption></figure><p>Another way to accomplish this would be to combine the three column windows first, dock the Timeline window at the bottom, and then separate the columns again.</p><p>At this point you can add whatever other windows you want to the different areas of your screen and then save your layout for easy access!</p><h3>Alternative Timeline Layout</h3><p>I personally don’t mind having the Animation and Timeline windows occupy the same area, but as an alternative layout, you could of course separate the windows, putting one above the other. Whenever you want to edit a Timeline clip in the Animation window, you’ll be able to do so without losing access to the Timeline window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uP8tWKDpK2pzxpKp7C559w.jpeg" /></figure><p>Hopefully this helps you with animating objects using Timeline or gives you ideas for other layouts that may help you in other scenarios. Even if rearranging windows to get the desired result isn’t straightforward, there’s always a way to do it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc642889e5b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Timeline’s Animation Extrapolation in Unity]]></title>
            <link>https://medium.com/@wesley.n.campbell/using-timelines-animation-extrapolation-in-unity-5666c439bd7a?source=rss-8fc0b56566e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/5666c439bd7a</guid>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[timeline]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[unity]]></category>
            <dc:creator><![CDATA[Wesley Campbell]]></dc:creator>
            <pubDate>Wed, 10 Jan 2024 12:55:48 GMT</pubDate>
            <atom:updated>2024-01-10T12:55:48.497Z</atom:updated>
            <content:encoded><![CDATA[<p>Unity allows you to control the behavior of animations in Timeline, including the space between clips. Using animation extrapolation, you can loop, ping pong, or continue animations after a clip has ended or even before it begins. Let’s take a look at how Timeline’s animation extrapolation works.</p><h3>Animation Extrapolation Types</h3><p>When the timeline playhead is in the middle of an animation clip, it will play the corresponding part of that animation. Animation extrapolation determines how an animation should play between animation clips. Therefore, any extrapolation setting will end once the playhead reaches a new clip.</p><p>The Post Extrapolation setting essentially extends the clip forward into the empty space after the clip ends and determines its behavior during that time. Similarly, the Pre Extrapolation setting essentially extends the clip backward into the empty space before the clip and determines its behavior during that time.</p><p>When you select an animation clip in the Timeline window, one of the sections in the Inspector is called Animation Extrapolation. By default, you will generally only find a Post-Extrapolate dropdown, which will be set to Hold. This dropdown will give you all the different options for what an animation clip should do once it ends in the timeline. Note that the icon after the clip will change depending on the chosen post extrapolation setting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*Jg5oAHMESm5oFNy4ZARZvQ.png" /><figcaption>Animation Extrapolation Options</figcaption></figure><p>This is what our example animation clips look like with the Hold setting and the clip lasting the duration of the animation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pox9Hw8_QmvuISxtj_a9xg.gif" /><figcaption>Animation Clips at Default Settings</figcaption></figure><p>If we shorten the clips at the end, the Hold setting will freeze the animation until the next clip starts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hRGb4GvLXo6SF1wWkFj3TA.gif" /><figcaption>Animation Clips with Post Extrapolation of Hold</figcaption></figure><p>The Loop setting will loop the portion of the animation that the clip allows until the next clip starts. Note that once the timeline reaches the end, it will not continue to use animation extrapolation settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3TGneczlSJiSYz5K6SpdSA.gif" /><figcaption>Animation Clips with Post Extrapolation of Loop</figcaption></figure><p>The Ping Pong setting will play the animation forward and backward depending on the start and end points of the clip.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q9beXJCH70sZyG16ZcHxFw.gif" /><figcaption>Animation Clips with Post Extrapolation of Ping Pong</figcaption></figure><p>The Continue setting will continue the animation as though the end point isn’t there until the next clip starts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ayIY6SvO_9YUGjXshBddg.gif" /><figcaption>Animation Clips with Post Extrapolation of Continue</figcaption></figure><h3>Enabling Pre Extrapolation</h3><p>Before we move on to pre extrapolation, let’s quickly explain the None setting for animation extrapolation. The None setting will reset the state of the object to what it was before the timeline started animating it until the next clip takes over.</p><p>In order to use pre extrapolation, the post extrapolation setting of the previous clip must be set to None, or there must be empty space with no preceding clip. Setting a clip’s post extrapolation to None allows the next clip to use pre extrapolation starting at the previous clip’s end point. Note that the extrapolation icon will show at the beginning of the clip when using pre extrapolation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ql1KYfnlzYGyOsVVDrwPhA.gif" /><figcaption>Animation Clips with Post and Pre Extrapolation of None</figcaption></figure><p>The Hold setting will snap to the starting frame of the clip and freeze there when the previous clip ends.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i2JwosBg0ECsdFZo8lQLuA.gif" /><figcaption>Animation Clips with Pre Extrapolation of Hold</figcaption></figure><p>The Loop setting will loop the animation clip into its starting frame when the previous clip ends.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F9i_wVwHdhVPwilbeXO-NQ.gif" /><figcaption>Animation Clips with Pre Extrapolation of Loop</figcaption></figure><p>The Ping Pong setting will play the clip forward and backward when the previous clip ends.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WZeh16bO2mKqofjvf2KFSw.gif" /><figcaption>Animation Clips with Pre Extrapolation of Ping Pong</figcaption></figure><p>The Continue setting should start playing the clip as though the start point isn’t there when the previous clip ends. At the time of writing this article, however, there is a bug with the Continue setting for pre extrapolation when playing forward, including in Play Mode. Because of this, I would recommend not using this setting until it gets fixed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rzaCNL83vns_BO8GyI3aYw.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kn_WDw8J95Zi6MQ9oPcXTg.gif" /><figcaption>Current Behavior of Pre Extrapolation of Continue (Left) vs. Intended Behavior (Right)</figcaption></figure><p>For the most part when editing clips together using Timeline, you will probably use the default Hold setting for post extrapolation. However, if you want to loop or ping pong an animation, Timeline makes it extremely easy without having to create new animations. And with that, you know everything you need to start editing and utilizing the space between your animation clips!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5666c439bd7a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bug Squashing in Unity: Erratic Timeline Movement]]></title>
            <link>https://medium.com/@wesley.n.campbell/bug-squashing-in-unity-erratic-timeline-movement-b3da6864144a?source=rss-8fc0b56566e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3da6864144a</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[timeline]]></category>
            <category><![CDATA[game-development]]></category>
            <dc:creator><![CDATA[Wesley Campbell]]></dc:creator>
            <pubDate>Mon, 11 Dec 2023 02:33:31 GMT</pubDate>
            <atom:updated>2023-12-11T02:33:31.337Z</atom:updated>
            <content:encoded><![CDATA[<p>If your Timeline playback isn’t working correctly and you’re getting erratic behavior from your playhead, you may have accidentally enabled Jog by pressing the keyboard shortcut J.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*QIJtGdFddYXfF2z8ifFPTg.gif" /></figure><p>To fix this, simply click on or switch to a different window and then back to Unity, and your playback should return to normal!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AwC0HQ_YOX1Wtw06aZIctg.gif" /><figcaption>Fixing Strange Jog Behavior</figcaption></figure><p>You can also unbind the shortcut by going to Edit &gt; Shortcuts and scrolling down to the Timeline category. Then, simply right-click on Jog and select Remove shortcut.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*QfRuLRU1XAlhZ2xVthmIDw.png" /><figcaption>Unbinding Jog Shortcut</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3da6864144a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigating the Timeline Window in Unity]]></title>
            <link>https://medium.com/@wesley.n.campbell/navigating-the-timeline-window-in-unity-f553eccc044a?source=rss-8fc0b56566e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f553eccc044a</guid>
            <category><![CDATA[timeline]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[learning]]></category>
            <dc:creator><![CDATA[Wesley Campbell]]></dc:creator>
            <pubDate>Sat, 09 Dec 2023 11:23:40 GMT</pubDate>
            <atom:updated>2023-12-09T11:23:40.189Z</atom:updated>
            <content:encoded><![CDATA[<p>Before going wild ordering different clips and actions in the Timeline window, it’s important to understand how it works. If you’ve worked in an NLE before, such as Premiere Pro or Final Cut, you’ll find that some things are similar, but be aware that others are very different. Let’s go over the basics of navigating the Timeline window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*-_zitME33aG8pg4QDYs0Sw.png" /></figure><h3>Top Bar Controls</h3><p>At the top left of the top bar, we have the play control bar. The Preview button at the beginning of the play controls determines whether the changes made to an object on the timeline will be reflected in the Scene view. Disabling the button will disable timeline changes, but scrolling or playing through the timeline will automatically reenable it.</p><p>The center five buttons are standard play controls. The first button skips to the very beginning of the timeline while the second goes back one frame. The center button will play or pause playback of the timeline. The fourth button goes forward one frame while the fifth skips to the end of the timeline. Note that the skip buttons are for the whole timeline, not just one clip.</p><p>Let’s quickly go over shortcuts for the play control bar. The play button is activated with the Spacebar. The &lt; and &gt; keys are for previous and next frame, respectively. To skip to the beginning or end of the timeline, hold Shift and press the &lt; or &gt; key. And while there is no button for this, holding Ctrl and pressing the &lt; or &gt; key will skip to the previous or next keyframe in a clip.</p><p>The last button on the play control bar toggles play range markers on and off. When toggled on, you can adjust the play range markers by dragging them around the timeline. Note that these markers only apply when previewing in edit mode, so they will be ignored in play mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nhf3YlZ2SaYbGe8izqrQOg.gif" /><figcaption>Adjusting Play Range Markers</figcaption></figure><p>The final section of the play control bar displays your current position on the timeline and will update while it plays. You can also type in a specific time to jump to that position on the timeline. Typing in a specific time can be done in any format, so 90, 1:30, and 1.5 will jump to the same position.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*GiufIhjaje70PwykaJ78LQ.png" /><figcaption>Play Control Bar</figcaption></figure><p>All the way to the right of the top bar, you’ll find a gear icon for timeline settings. Clicking on it will give you a shortcut to the Preferences page for Timeline as well as some other options. Of particular use is what format you want to use to display time at the top of the timeline. As a video editor, I feel most comfortable using Timecode, which displays the full number of seconds followed by the remaining frame count. Frames will display the true frame number, and Seconds will display the number of seconds in decimal form.</p><p>As an example, let’s assume we have a frame rate of 60 frames per second and we want to find the frame at exactly one and a half seconds. In Frames, this would display as 90. In Timecode, this would display as 1:30. In Seconds, this would display as 1.5. As a reminder, typing any of these into the position indicator of the play control bar will jump you to the same position.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/191/1*rMrVBYCdEIZBtf9o9KvuTw.png" /><figcaption>Top Bar Settings</figcaption></figure><p>The plus button in the top left under the play control bar allows you to add different track types. These will be covered in future articles. You can also bring up the track creation menu by right-clicking in the track area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/178/1*QrrdjMfGwwqF_COnyzMsZg.png" /><figcaption>Plus Button</figcaption></figure><p>The next group of buttons are three editing mode buttons. These allow you to switch between different editing modes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/103/1*j20lqFl_ngeMWPSmIAIrHQ.png" /><figcaption>Editing Mode Buttons</figcaption></figure><p>The first, Mix Mode, allows you to drag your clips around and add new clips nondestructively. Clips that overlap will transition into each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V3i8HrMjebbpsbF8nbtinw.gif" /><figcaption>Mix Mode Editing</figcaption></figure><p>The second, Ripple Mode, will move everything on the timeline after the selected clip, and inserting a new clip will move all clips after it to make space. Clips cannot overlap while moving them around in this mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4iz6DnGnmN7uP-5r1Dkdvg.gif" /><figcaption>Ripple Mode Editing</figcaption></figure><p>The third, Replace Mode, allows you to drag your clips around and add new clips without creating transitions. When clips are placed, overlapped clips will be trimmed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8jnfXuKrpzPX-JFdadHnow.gif" /><figcaption>Replace Mode Editing</figcaption></figure><p>The button that looks like a pin is a toggle that shows or hides markers on the timeline.</p><h3>Timeline Controls</h3><p>To move the playhead in the timeline, click or drag in the timeline area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bXsw9IMt5WLwJmbvaTS84g.gif" /><figcaption>Moving the Playhead</figcaption></figure><p>To resize the timeline, scroll up or down with your mouse wheel, hold the alt button and drag with the right mouse button, or drag the ends of the scroll bar at the bottom of the Timeline window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XIWNaF7iiBnX6JdZ4iv3mw.gif" /><figcaption>Resizing the Timeline</figcaption></figure><p>To move around the timeline, drag with the middle mouse button, hold down alt and drag with the left mouse button, or move the scroll bars at the bottom and side of the Timeline window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gvszH4zZCNPeI9Y4Y8rqtQ.gif" /><figcaption>Moving Around the Timeline</figcaption></figure><p>In order to frame all clips in the timeline, press the FrameAll key, which is A by default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Z08G-iK70_KP_kBU1oyeQ.gif" /><figcaption>Frame All Clips</figcaption></figure><p>To frame a single clip, select it and press the Frame key, which is F by default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EgWVHF3klNQTxFcxiePsGg.gif" /><figcaption>Frame Single Clip</figcaption></figure><p>You can right-click on the playhead itself, which will allow you to insert empty frames or select certain clips based on where the playhead is located.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ILHlSlmbaXfsbUnG-_AlXQ.gif" /><figcaption>Playhead Menu Options</figcaption></figure><p>Finally, you can trim or split clips in the timeline as well. Trim the beginning of the clip, the In Point, to the location of the playhead using I. Trim the end of the clip, the Out Point, to the location of the playhead using O. Split the clip into two clips using S. Keep in mind that when setting the out point, the current frame will not be included, and when splitting a clip, the current frame will be the start of the second clip.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l8wHV5DxSBXar2_fsW-gaQ.gif" /><figcaption>In Point, Out Point, and Split</figcaption></figure><h3>Keyboard Shortcuts</h3><p>In order to change your keyboard shortcuts, you can access the shortcuts window with Edit &gt; Shortcuts. From there, you can double-click the shortcut you want to change and press the new shortcut key. You can also right-click a shortcut to reset it to default or unbind it. Feel free to look through the shortcuts to see what you can do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*yATYQK_vA7wSAIj95WNshw.gif" /></figure><p>And with that, you know everything you need to get started editing clips comfortably using Timeline!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f553eccc044a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Basic Animations in Unity Using Timeline]]></title>
            <link>https://medium.com/@wesley.n.campbell/creating-basic-animations-in-unity-using-timeline-067b1c57726c?source=rss-8fc0b56566e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/067b1c57726c</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[timeline]]></category>
            <category><![CDATA[game-development]]></category>
            <dc:creator><![CDATA[Wesley Campbell]]></dc:creator>
            <pubDate>Thu, 07 Dec 2023 10:29:08 GMT</pubDate>
            <atom:updated>2023-12-07T10:29:08.291Z</atom:updated>
            <content:encoded><![CDATA[<p>Rather than creating animations and setting up individual animators per object, Timeline allows you to create animations for several objects in one place. Then you can line them up so that everything is timed perfectly, something that is very difficult when working with multiple animator components. Let’s go over the basics of how to do this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hwBELoF8Q9XhArXrjhccgg.gif" /></figure><h3>Setting Up Timeline</h3><p>Using the Package Manager, make sure Timeline is installed and imported into your project. Once it is, open the Timeline window by going to Window &gt; Sequencing &gt; Timeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*LhclZz3SxVcFQWOu1kxhDw.png" /><figcaption>Opening the Timeline Window</figcaption></figure><p>Now let’s create a new empty object in the Hierarchy window and call it Sequencer for this example. With the Timeline window open and the Sequencer object selected, click the Create button in the Timeline window to create a new Director component on the Sequencer object. This will prompt you to create a new Timeline asset, so choose a location and name you’re happy with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4aRhohumTnZfzrfxSzBuoA.png" /><figcaption>Creating a New Director Component</figcaption></figure><p>The Director component controls the playback of the Playable asset that it is given. The Timeline asset is a type of Playable asset that takes the form of a timeline and can be used with the Timeline window to edit clips together like a non-linear editor (NLE).</p><p>Now you should see a timeline in the Timeline window when the Sequencer object is selected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KcZmChOevTPeuOypC4enVw.png" /><figcaption>Empty Timeline</figcaption></figure><h3>Creating Object Animations</h3><p>Let’s create a cube to start animating. Dragging the cube into the timeline window will give us options as to what kind of track we can create for this object. Since we want to animate its movement, we’ll create an Animation Track.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/203/1*rPcgeGe6cEAGLwdME5bN9Q.png" /><figcaption>Creating an Animation Track</figcaption></figure><p>In the toolbar for the newly created track, we can select the record button to start making keyframes by moving the cube around, just like we would from the Animation window. For this example, we’ll set a keyframe with its starting point at 0 seconds and 2 seconds and set the cube’s x position to 5 at 1 second.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*2Onkni3e4FWwBtXK8i1rKw.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*Dise80ulY04YhHmI551R9w.gif" /><figcaption>Hitting the Record Button (Left) and Adding a Key to the Track (Right)</figcaption></figure><p>Once the three keyframes are created, we can deselect the record button to stop making changes and press the play button to see our new animation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*aGiYhynCklpWwScyE9WbLw.gif" /><figcaption>Previewing New Animation</figcaption></figure><p>Our animation is looking good! At the moment, though, these new keyframes are difficult to change. You can’t select them to move or change them in the Timeline window. You can right-click on the track and choose Edit in Animation Window or just double-click the track to open the keyframes in the animation window to move or change them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*U0WyxBsFMaqwMgasr1i5-w.png" /></figure><p>If we add more keyframes, they will be added to the timeline and be treated as a single animation. If we want to create multiple animations, however, we can convert the track to a Clip Track, which will be able to manipulate multiple clips instead of just being a single animation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*MiuO_djVPAorYIkgAWp_GQ.png" /></figure><p>The keyframes we created will become a new clip stored in the Timeline asset itself. To create a new clip, we can move the playhead to an empty space and add a new keyframe like we did before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*66vSD32iAXhRnPkcc81pdA.gif" /><figcaption>Creating a New Clip by Adding a Key in Blank Space</figcaption></figure><p>If a keyframe is placed outside of the new clip, another new clip will be created, so we’ll want to make our new clip the right length to fit all our keyframes. To make our new clip 2 seconds long like the first clip, we can drag it out manually to be 2 seconds long. To ensure accuracy, we can also drag the clip to be longer and use the Trim End function to set the end point of the clip exactly where we want it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*z6LjYzhxCNNB3oY3dkTzOw.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*_M2Fi3MBE6kA3RBm3Vjqpw.png" /><figcaption>Stretching to Exact Duration (Left) and Using Trim End (Right)</figcaption></figure><p>Now that our clip is the right length, we can add our end keyframe and our middle keyframe. This time, we’ll set the cube’s x position to -5. Then we’ll repeat the process and set the cube’s y position to 5.5 for the middle keyframe.</p><p>Now that we have 3 clips, we can move them around on the timeline to easily retime each action! We can easily add more or less time in between or reorder the actions as we wish. There is also a snap feature so the clips will snap together when the beginning and ending points are close to make it easier to synchronize clips.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wbRdtjFi2FhAV3ou7R0TIA.gif" /><figcaption>Moving Clips Around on the Timeline</figcaption></figure><p>You can also transition clips into each other simply by dragging them on top of each other. This will blend the two animations together. Note that you can’t blend more than two animations at once.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q-R3wE2C_FSeDPQ3D3NrkQ.gif" /><figcaption>Blending Clips Together</figcaption></figure><p>If you want a clip to gradually start or end, you can create an Ease In or Ease Out transition for a clip by holding the Ctrl key and dragging the start or end of the clip.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ILAPzi4DU6MpGB1NSHb8rA.gif" /><figcaption>Creating an Ease In and Ease Out</figcaption></figure><p>With a clip selected, you will find several options in the Inspector, such as Start, End, Duration, Ease In, and Ease Out values, which reflect the changes made in the Timeline window. Values can be set here if you wish.</p><p>One important value you can find here is the Speed Multiplier. You can use this to speed up or slow down a clip without going to the animation window to change the keyframes themselves. This can be especially useful when using complex animations with lots of keyframes, such as character animations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*-y8bEHudvsrSEJ63v9x0dg.png" /></figure><h3>The Playable Director</h3><p>The Director component has a few options to make sure your playables play back correctly.</p><p>The Update Method dropdown determines the timing that its playable should update. The DSP Clock is used for audio. Game Time preserves changes to Time.timeScale, so the playable will play in slow or fast motion to match the game speed. Unscaled Game Time ignores changes to Time.timeScale, so the playable will play in real time no matter how the game speed changes. Manual requires you to set the Director’s clock manually through scripting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*NfS_PHYXMkO0wr8_0HOb0w.png" /><figcaption>Director Update Method</figcaption></figure><p>The Play on Awake checkbox determines whether the Director starts playing its playable as soon as it is enabled.</p><p>The Wrap Mode dropdown determines what the Director should do when it reaches the end of its playable. Hold holds on the last frame of the playable until playback is interrupted. Loop plays the sequence from start to end repeatedly until playback is interrupted. None resets all animated properties to the values they had before playback.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*w1paQB2I-3orfJLAbJpF-w.png" /><figcaption>Director Wrap Mode</figcaption></figure><p>Initial Time adds a delay in seconds between telling the Director to start playing and the Director actually starting to play its playable.</p><p>The Bindings list shows the objects that will be controlled by this Director’s playable when played.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*SBrS5f0pEZHgZFiepTmwRQ.png" /><figcaption>Director Bindings List</figcaption></figure><p>And with that, you know everything you need to get started making basic animations and manipulating them using Timeline!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=067b1c57726c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating an Interactive Security Camera Setup in Unity with Cinemachine]]></title>
            <link>https://medium.com/@wesley.n.campbell/creating-an-interactive-security-camera-setup-in-unity-with-cinemachine-4275903ac935?source=rss-8fc0b56566e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4275903ac935</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[cinemachine]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[learning]]></category>
            <dc:creator><![CDATA[Wesley Campbell]]></dc:creator>
            <pubDate>Tue, 05 Dec 2023 09:35:50 GMT</pubDate>
            <atom:updated>2023-12-05T09:35:50.180Z</atom:updated>
            <content:encoded><![CDATA[<p>Rather than just setting up automatic camera transitions such as with a Cinemachine Blend List, it’s possible to give the player control over which camera is used. This is commonly seen in racing games or games with security camera systems that the player can hack into. Let’s set up an interactive security camera setup with different types of cameras as an example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aWeut0pPyiMWJAzOvVtM8A.gif" /></figure><h3>Activating and Switching Security Cameras</h3><p>In the center of the hub area of this level, there is a trigger collider to switch to the security cameras in the hallways. We’re going to use some simple scripting to switch through these cameras. It’s fine if we haven’t set up any cameras yet, because this script will allow us to scale up to as many cameras as we want.</p><p>First let’s store the virtual camera that’s following the player as the player camera. Then we’ll set up an array to store all our security cameras and an integer to tell us which camera we are currently using. Note that we store VirtualCameraBase for the security cameras so that we can add different kinds of virtual camera setups such as a Blend List.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UPuwS0FCZY0OssflQ3qiCg.png" /><figcaption>Storing the Player and Security Cameras</figcaption></figure><p>When the player enters the trigger collider, we want to switch to the security cameras, and we want to switch back to the player camera when they exit the collider. Let’s do this by modifying the player camera’s priority to switch between 9 and 12 to allow 10 and 11 to belong to the security cameras.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*2SZzHrjbKNVSL_zrlBaDTA.png" /><figcaption>Adjusting the Player Camera Priority</figcaption></figure><p>Now we want to allow the player to switch between the different security cameras by pressing the C key. We’ll cycle to the next camera in the array by switching the current one to the lower value of 10. Then we’ll add 1 to the integer representing our current camera (or cycle it back to 0 when it reaches the max length of the array) and switch that camera to a priority of 11.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4F8VuAtjesJy9eB2tv3RXQ.png" /><figcaption>Cycling Through Security Cameras by Pressing C Key</figcaption></figure><p>As long as our player is inside the trigger collider, they can cycle through the available cameras at will. Now we just need to set them all up!</p><h3>Setting Up the Security Cameras</h3><p>For this example, we’ll set up three cameras, and the Default Blend will be a Cut. First, let’s set up a static camera from the hallway that the player has just come from. We’ll create a basic Virtual Camera and position it where our security camera sits in the hallway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qagoTOOyUswiUfH7oXmuCQ.png" /><figcaption>Static Security Camera</figcaption></figure><p>We can set the Body and Aim dropdown to Do Nothing to keep the camera static. Then we can set our desired FOV and angle the camera to our liking. Then we just need to add the camera to the trigger script’s array and we’re finished with our first security camera!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9obrDbUkTbAc_mMNJvEgAw.gif" /><figcaption>Static Security Camera</figcaption></figure><p>Next let’s set up a Blend List for a camera that will pan between the hub area and a connected hallway. We’ll use similar settings as our static camera for the first camera, and we’ll angle the second camera toward the connected hallway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d1rCaHz9GQOG5yFWhelBnA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cSe8hg-bH_oYqqAUksII4g.png" /><figcaption>Virtual Cameras Facing Connected Hallway (Left) and Hub Area (Right)</figcaption></figure><p>We can check the Loop box so that the security camera will go back and forth between the two positions.</p><p>When setting up a camera like this, there is an important thing to keep in mind. When switching to a Blend List camera, it will always start from the beginning of the instruction list. The cameras won’t pan back and forth and allow you to switch in the middle of their motion. If you want to achieve that, you’ll have to code or animate a virtual camera to pan back and forth continuously.</p><p>Another important thing to know is that the Blend List will wait the whole Transition and Hold durations of the first instruction before transitioning to the next. Our camera behaves as desired with the instructions in the below example, but it will wait too long to start moving.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*KZU1UmVHn-CJdTxESd9cSg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TV-f_0WYvg_cCqX82HOfBQ.gif" /><figcaption>Panning Movement with a Three-Second Starting Delay</figcaption></figure><p>If we want the camera to start moving the moment we switch to it to give the illusion of a continuously panning camera, we can start with a cut blend with a Hold duration of 0. This way the first instruction takes no time at all and we can still set up our panning movement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*aeLE2iSy2Vbqqc-jZX5enQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*72ZTq3SgEdkq2dL6zWATaQ.gif" /><figcaption>Panning Movement with No Starting Delay</figcaption></figure><p>Once we’re happy with our panning movement and starting delay, we just need to add the Blend List camera to the trigger script’s array and we’re finished with our second security camera!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U8lorlYuRxYrYvfjoHA-hA.gif" /><figcaption>Panning Security Camera</figcaption></figure><p>Finally, let’s set up a camera that the player can control with their mouse. We’ll create a basic Virtual Camera and set its Aim setting to POV. Now we can set our FOV setting as normal, but instead of rotating the camera using its Transform component, we can instead set the values of the Value fields under the Vertical Axis and Horizontal Axis sections.</p><p>From there, we can limit how far the player can look by setting the Value Range for the two Axis sections. If we check the Wrap box, the camera will snap from its min value to its max value if it continues traveling in that direction, and vice-versa. This is usually only used when allowing a full circle of movement, so we’ll keep the Wrap box unchecked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*EY4gfhBRUsi7vwnAM8xaiA.png" /><figcaption>Example Value Range Settings</figcaption></figure><p>Once the Value Range values have been set, we can also set the Speed, Accel Time, and Decel Time values to make our camera movement feel comfortable.</p><p>You can also enable Vertical Recentering and/or Horizontal Recentering to recenter the camera after a certain amount of time of the player not moving the camera.</p><p>Once we’re happy with our POV settings, we just need to add the camera to the trigger script’s array and we’re finished with our final security camera!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ajbEncpJYzywH2xIIIuZvA.gif" /><figcaption>POV Security Camera</figcaption></figure><p>And with that, we have a working interactive security camera setup! This basic setup can easily be changed or expanded to suit the needs of various projects. For example, the trigger could be replaced with an interactable object, or individual cameras could be enabled with separate keys instead of being cycled through with a single key. Whatever a project’s need, Cinemachine makes it simple to set up!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4275903ac935" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Examining the Cinemachine Brain: Custom Transitions Per Camera]]></title>
            <link>https://medium.com/@wesley.n.campbell/examining-the-cinemachine-brain-custom-transitions-per-camera-f8fbfc9fe9e2?source=rss-8fc0b56566e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8fbfc9fe9e2</guid>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[cinemachine]]></category>
            <dc:creator><![CDATA[Wesley Campbell]]></dc:creator>
            <pubDate>Wed, 29 Nov 2023 04:53:39 GMT</pubDate>
            <atom:updated>2023-11-29T04:53:39.983Z</atom:updated>
            <content:encoded><![CDATA[<p>When switching between virtual cameras, sometimes you’ll notice that the transition doesn’t look the way you want between certain cameras. But if you change the default blend to make it look better, it will change the transition for all of your cameras. Do we have to find a happy medium and keep all our camera transitions there?</p><p>Fortunately, no! The Cinemachine Brain does have a Default Blend setting, but it can be overridden for specific camera transitions. Let’s take a look at the Cinemachine Brain’s settings and how to create custom transitions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*74oJnqSBsdcn4llaAwRv5A.gif" /></figure><h3>Cinemachine Brain Settings</h3><p>The Show Debug Text checkbox will display the current active virtual camera and the progress of the transition in a text box in the game window for debugging.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4kSNeKfJ8C99EHPMNsMN4w.gif" /><figcaption>Switching Cameras with Show Debug Text Enabled</figcaption></figure><p>The Show Camera Frustum checkbox will make sure the camera frustum is always showing in the Scene window, even when the camera is not selected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k-Ypf1msFd5-BoTmXK7gWA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GuPj6kUA4kmXB3We0Tqcaw.png" /><figcaption>Camera Not Selected with Show Camera Frustum Checked (Left) and Unchecked (Right)</figcaption></figure><p>The Ignore Time Scale checkbox will cause camera transitions to ignore any changes to the time scale in the game, causing all values to operate in real time. Leave this unchecked if you want the camera transitions to move slower in slow motion and faster in fast motion when changing the time scale.</p><p>The World Up Override field takes a Transform and uses its local Y axis to determine the Up direction for all virtual cameras. This can fix behavior relating to virtual cameras looking straight up or down, such as in a top-down game.</p><p>The Update Method dropdown determines when virtual cameras should update their Body and Aim targets. Fixed Update is useful if all targets are moved during FixedUpdate. Late Update is useful is all targets are moved during the normal Update function. Smart Update allows Cinemachine to choose between the two and is the recommended option. Manual Update requires you to manually tell when the virtual cameras should update in scripting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*BiS_NDMf5TdnlPbl1a6Cnw.png" /></figure><p>The Blend Update Method dropdown determines when the camera’s transform should be updated based on the current transition between cameras. As with most camera movements, Late Update is the recommended setting. Fixed Update should only be used if the Update Method is set to Fixed Update and there is jitter in the transition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*V9geGAw1vUVwsxPjQMjEjA.png" /></figure><p>The Default Blend is the transition that will be made between all virtual cameras unless overridden, which we will discuss in the next section. It has several options to choose from, each of which will be visually demonstrated below with a duration of 1 second.</p><p>The Cut blend is a transition with a duration of 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NMzMoRADCoSfm1cexfI1NQ.gif" /><figcaption>Cut Blend</figcaption></figure><p>The Ease In Out blend creates a movement with a slower beginning and ending.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*utXxR5mGyBk27_NhY0ku6w.gif" /><figcaption>Ease In Out Blend</figcaption></figure><p>The Ease In blend create a movement with a slower ending.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7xGtskfO6dJfMkecHKqbyA.gif" /><figcaption>Ease In Blend</figcaption></figure><p>The Ease Out blend creates a movement with a slower beginning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*06y3u17-HLnCsVYo673Vag.gif" /><figcaption>Ease Out Blend</figcaption></figure><p>The Hard In blend creates a movement with a faster ending.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K0eE95jxF1ZQypMha-lBvg.gif" /><figcaption>Hard In Blend</figcaption></figure><p>The Hard Out blend creates a movement with a faster beginning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DtOQ6nsgdD-i105WENc-AQ.gif" /><figcaption>Hard Out Blend</figcaption></figure><p>The Linear blend creates a movement with consistent speed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kyvEPxq2hI8H63Ah6iZPeQ.gif" /><figcaption>Linear Blend</figcaption></figure><p>The Custom blend allows you to create your own transition curve. Clicking on the picture of the little graph will open a window that will allow you to customize the curve.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*EnVRbHMZ2V5xKM8pQh828g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*kXGD5fTMID1m2bYz5VZ7yw.png" /><figcaption>Custom Blend Graph</figcaption></figure><h3>Creating Custom Transitions</h3><p>For some camera transitions, you may not want to use your default blend. That’s where Custom Blends come in. Click on the Create Asset button next to the Custom Blends field to create a custom blend asset for this Cinemachine Brain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*BB53U93sI0NIJwVIDNmMAw.png" /><figcaption>Create Custom Blends Asset</figcaption></figure><p>Once your asset is created, you can set custom blends when transitioning from one specific camera to another, or any camera to a specific camera. In the following example, we have different transition types when moving from cam 1 to cam 2 to cam 3 and back to cam 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*0Uduwwtzd7zli5PL-ZXOiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*74oJnqSBsdcn4llaAwRv5A.gif" /><figcaption>Custom Transitions Per Camera</figcaption></figure><p>Notice, however, that these transitions are defined in one direction. In this case, there is no transition defined for cam 3 to cam 2, for example, so the default blend will still be used. This means you get full control over how cameras switch to each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C_XvDvxDNyrrMktwmIZ1rA.gif" /><figcaption>Default Blend for Undefined Transitions</figcaption></figure><p>And with that, you know everything you need to get started using the Cinemachine Brain and creating custom transitions from one camera to another!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8fbfc9fe9e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cinemachine Preset Cameras: 2D Camera]]></title>
            <link>https://medium.com/@wesley.n.campbell/cinemachine-preset-cameras-2d-camera-e1ab2fbd6487?source=rss-8fc0b56566e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1ab2fbd6487</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[cinemachine]]></category>
            <category><![CDATA[unity]]></category>
            <dc:creator><![CDATA[Wesley Campbell]]></dc:creator>
            <pubDate>Sat, 18 Nov 2023 07:35:59 GMT</pubDate>
            <atom:updated>2023-11-18T07:35:59.940Z</atom:updated>
            <content:encoded><![CDATA[<p>While 3D functionality is important, Cinemachine’s support for 2D cameras is the deciding factor for a lot of games. Turns out, Cinemachine has a 2D camera preset that gives us everything we need!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mqkLFr9QE_9SGEZR4aL1hw.gif" /></figure><h3>Setting Up the 2D Camera</h3><p>To create a 2D Camera, right-click in the Hierarchy window and select 2D Camera under the Cinemachine menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*Vp5FotjYzEEjU9KsN7pfNQ.png" /><figcaption>Creating a 2D Camera</figcaption></figure><p>A 2D camera is mostly a normal virtual camera, but its default Body and Aim settings are Framing Transposer and Do Nothing. If you want to use a 2D camera for your whole game, make sure your main camera’s projection type is set to Orthographic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*iye3vbg1isQoJ11m1L8Jxw.png" /><figcaption>Setting Main Camera to Orthographic</figcaption></figure><p>If you want your main camera to switch between 3D and 2D based on which virtual camera you’re using, you can use the Mode Override in the virtual camera’s settings under Lens &gt; Advanced. This will cause your camera to become a 2D camera when switching to this virtual camera. Keep in mind that this setting will persist unless another virtual camera also has an override, so all your other cameras should use the Mode Override as well. In general, if you are planning to switch back and forth, you should set your 2D virtual cameras’ overrides to Orthographic and your 3D cameras’ overrides to Perspective or Physical.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*43i9-xiIKhLbXK5SWJ2ZAQ.png" /><figcaption>Setting the Virtual Camera’s Mode Override</figcaption></figure><p>At this point, you can set up your virtual camera as normal, such as assigning an object to the Follow field and setting the offset, lookahead time, damping, and screen placement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Wp63Cndj--g7CrNwlmz_g.gif" /><figcaption>Basic 2D Camera Settings</figcaption></figure><p>Here we can see that the character has reached the end of the map, so we want the camera to stop moving and allow the character to move offscreen. To do this, we can set up a confiner to limit where the virtual camera is allowed to look.</p><p>Under the Add Extension dropdown on our 2D camera, we can add a Confiner or a Confiner2D. Despite using a 2D camera, we’ll choose a regular Confiner for this example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*B5aJlYAp7J6fyRhqTq3ETw.png" /><figcaption>Creating a Cinemachine Confiner</figcaption></figure><p>Under the Confine Mode, you can choose between 2D and 3D. The 2D mode requires you to use either a PolygonCollider2D or a CompositeCollider2D, which can be a bit cumbersome to set up. For a simple box confiner like we want to make, we’ll switch to 3D mode.</p><p>Now we need to create a new object with a collider component. When adjusting the collider’s settings, keep in mind that it is a 3D volume we are allowing the 2D camera to move in. For example, if our 2D camera’s Z position is set to be -10 units, then we need to make sure our confiner’s Z Center and Size allow the camera to be there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*3cckw7c3NdMrcoJwCXtMBA.png" /><figcaption>Example Box Collider Settings for Confiner</figcaption></figure><p>In the Scene view, you can see where the collider will allow the camera to look. You can use this to visualize what you will allow the camera to see.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5U4wlrHbDNjwFTgpwT3xBQ.png" /><figcaption>Box Collider in Scene View</figcaption></figure><p>Once your collider is set up, you can assign it to the Bounding Volume field in the confiner script. Once it’s assigned, selecting the virtual camera will show the bounding volume in yellow in the Scene view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PhLwqlrKsDmcdpmKsNdpGA.png" /><figcaption>Confiner Bounding Volume in Scene View</figcaption></figure><p>The Confine Screen Edges checkbox determines whether the boundary confines the center of the camera or the camera’s view. In our case, we want the camera’s view to be confined, so we’ll leave the box checked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*9xKz2yYbmc0hkRg_1xM2wA.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*Q2u5Z0ynMUdt2ZdobS7Arw.gif" /><figcaption>Confine Screen Edges Checked (Left) vs. Unchecked (Right)</figcaption></figure><p>The Damping slider sets the delay for the camera to correct back into the confiner’s defined space. Setting this above 0 can lead to some strange behavior, however. Cinemachine seems to use the object’s velocity to return the camera to the confiner, rather than its position. In addition, if the object is offscreen but is moving toward the confiner, the camera will move further into the confiner area.</p><p>The following examples use a Damping value of 1 and a Lookahead Time value of 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iG4EaDnc9lorztPVlVjZMQ.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zVKEiGH2hiG9uj2sixTOnQ.gif" /><figcaption>Damping When Moving Outside the Confiner (Left) and Coming Into the Confiner(Right)</figcaption></figure><p>If you need a more complex camera confiner, you can always play around with the Polygon and Composite colliders.</p><p>And with that, you know everything you need to get started using Cinemachine for 2D cameras!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1ab2fbd6487" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Combining Cinemachine Presets]]></title>
            <link>https://medium.com/@wesley.n.campbell/combining-cinemachine-presets-a4b4d70976d8?source=rss-8fc0b56566e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4b4d70976d8</guid>
            <category><![CDATA[cinemachine]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[game-development]]></category>
            <dc:creator><![CDATA[Wesley Campbell]]></dc:creator>
            <pubDate>Wed, 15 Nov 2023 10:13:04 GMT</pubDate>
            <atom:updated>2023-11-15T10:13:04.636Z</atom:updated>
            <content:encoded><![CDATA[<p>For most games, using one virtual camera or camera preset won’t cover all your needs. Once you learn how to use Cinemachine’s different tools, it becomes all about how you combine those elements into a larger system. Let’s create a small example to demonstrate how different Cinemachine presets can be combined into a larger system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*KGmPrzb-pW7w7hnMI4zJRA.gif" /></figure><h3>Setting Up the State-Driven Camera</h3><p>First, let’s import Unity’s Third Person Character Controller to give us a basic animation tree and some basic locomotion controls. I’ve replaced the default model and animations, and I’ve added aiming and death animations as well.</p><p>For this Cinemachine example, we’ll use a state-driven camera to switch between different cameras for our third-person camera setup.</p><p>Under the state-driven camera, let’s create four cameras. Two cameras will be FreeLook cameras to look around while walking and sprinting, and we’ll have a normal virtual camera for aiming and a BlendList camera for our death sequence.</p><p>For the State list, we’ll click on the plus button in the corner and select All Unhandled States. Then we’ll assign the correct virtual cameras to their corresponding animation states.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*fZj4qdWWtclF82QqYyeLyg.png" /><figcaption>Example State-Driven Camera Setup</figcaption></figure><p>Now let’s set up the cameras that we’ll be switching to.</p><h3>Setting Up the FreeLook Cameras</h3><p>We can set up a FreeLook camera and adjust the settings how we like for the standard walking camera. Then, we can duplicate this camera and expand the Rigs’ radii and add some camera shake to make our sprinting camera more dynamic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*wOVHVlTDdXj5XB84unKYIg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*pMIL5j7LnQcZmOoMtZfi2w.png" /><figcaption>Walking Rigs (Left) and Sprinting Rigs (Right)</figcaption></figure><p>An immediate problem that occurs when trying to switch between these two FreeLook cameras is that the new camera will revert to its old position rather than keeping the new position the player has moved to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CT6qGf9LrGwFjRSev5XA1A.gif" /><figcaption>Switching Between Two FreeLook Cameras</figcaption></figure><p>To fix this, we can go into the Transitions section for each of the FreeLook cameras and check the Inherit Position checkbox. This will make the camera attempt to match the current position of the camera when returning to the FreeLook camera.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JEmcyE1ShrgFwvmplkyTnA.gif" /><figcaption>Inheriting Position When Switching Between Two FreeLook Cameras</figcaption></figure><h3>Setting Up the Aim Camera</h3><p>Our aim camera will be a simple virtual camera that follows and looks at the player and is set to look over their shoulder when they aim.</p><p>Unfortunately, when the aim is released, the FreeLook camera will return to a default position that isn’t where we want it to end up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*in3zqtRhr7TNbrIS7LLTDA.gif" /><figcaption>Problem Switching Out of Aim Camera</figcaption></figure><p>There doesn’t seem to be a way to set a default FreeLook camera position, so the best way I’ve found to fix this so far is to do some scripting. We’ll create a function that sets the x and y axis values manually, and we’ll call this function when the aim button is released.</p><p>If we set the x and y axis values immediately, however, we get inconsistent behavior. I believe this is due to an order of execution issue between Cinemachine and scripts. One way to fix this is to delay the setting of the x and y axis values by one frame to ensure that your manual values overwrite the Inherit Position value of the FreeLook camera. For this example, I found that setting the y axis to 60% of its max height was good, and I manually adjusted the amount the x axis needed to be shifted in the editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LcdnTRFMCYxxF4__JapfOg.png" /><figcaption>Delaying Setting Manual X and Y Axis Values by One Frame</figcaption></figure><p>When our ResetFreeLookCamera function is called when the aim button is released, our camera reset is much better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oiq7NohRTJ8_WVVzVfQzlA.gif" /><figcaption>Switching Out of Aim Camera Working Correctly</figcaption></figure><h3>Setting Up the Blend List Camera</h3><p>When our character dies, we want a cinematic shot starting close to the face and slowly zooming out to the sky. This is easy to accomplish with only two cameras in a blend list. The first camera will be positioned close to the character’s head and will follow and look at it, and the second camera will be positioned much higher and will follow and look at the player.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iiVIvAL2JjMfK_zZ8oleAw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bIVTgH9ig0mM6mqGaPXFFQ.png" /><figcaption>First Camera Before Death Animation (Left) and Second Camera After Death Animation (Right)</figcaption></figure><p>Once these cameras are set up, we can decide the animation between the two with the Blend List settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*C9HGFoiSxrQVFRVlrlfv3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*rRB1tpjItxe6BNqNAX8RAg.gif" /><figcaption>Blending Between Two Cameras Working Correctly</figcaption></figure><p>The movement of the first camera is preserved while switching to the second camera, making for a cinematic shot with some impact, without having to do any extra work.</p><h3>Putting Everything Together</h3><p>Cinemachine is all about combining several elements together into a bigger system. Here we’ve created a system that can support several cameras for different types of player movement. More cameras could be added easily, such as for crouching and jumping.</p><p>But the main point is that each of these entire setups can count as a single camera. For example, the Blend List we used is a setup involving multiple cameras that is treated as a single camera. Remember, this whole system we’ve set up in this article is a single State-Driven camera that can be switched off of easily, since it’s considered a single camera.</p><p>You could create an entire separate setup for the same player movement for a different game mode, such as a stealth game mode, and easily switch between the two. This whole system could be part of a subsystem, just like the Blend List was a subsystem of this system.</p><p>Don’t feel like you need to get all of your functionality out of one camera or one type of camera. Don’t feel like you need to fit everything into one system. Learn the different things Cinemachine can do and combine and organize them as you wish. It really is one of the best packages Unity has released.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*KGmPrzb-pW7w7hnMI4zJRA.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4b4d70976d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cinemachine Preset Cameras: Target Group Camera]]></title>
            <link>https://medium.com/@wesley.n.campbell/cinemachine-preset-cameras-target-group-camera-0d2adbac434a?source=rss-8fc0b56566e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d2adbac434a</guid>
            <category><![CDATA[cinemachine]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[unity]]></category>
            <dc:creator><![CDATA[Wesley Campbell]]></dc:creator>
            <pubDate>Wed, 01 Nov 2023 07:44:16 GMT</pubDate>
            <atom:updated>2023-11-01T07:44:16.909Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s a lot more difficult to keep multiple things in frame as opposed to just one thing. Luckily, Cinemachine has a great way to set up a camera to automatically move and frame its shot to keep everything in frame and customize the behavior as well!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2fCTwgR8T9gwug8WFVKXnA.gif" /></figure><h3>Setting Up the Target Group Camera</h3><p>To create a Target Group camera, right-click in the Hierarchy window and select Target Group Camera under the Cinemachine menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*EO3o8rOaBF2mzMBNoOMr7A.png" /><figcaption>Creating a Target Group Camera</figcaption></figure><p>This will create a new virtual camera and a Cinemachine Target Group that will be assigned to the virtual camera’s Follow and Look At fields. The virtual camera will also have its Body behavior set to Transposer and its Aim behavior set to Group Composer.</p><p>The Target Group will move and rotate around to be in the center of the objects in its target list. For each object you add, you can set its radius in units to help the component calculate the bounding boxes for each object correctly. You can also set each object’s weight, which affects the calculation of the center of the objects, as higher weight values make the calculation tend toward staying closer to those objects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*6vzho37tqfDZfeK7ir1zmw.png" /><figcaption>Example Values for Cinemachine Target Group</figcaption></figure><p>If the Target Group is in the virtual camera’s Follow field and the Body mode is set to Transposer, the camera will follow the position of the Target Group. You can move the camera around or adjust its Follow Offset so that the camera itself is not in the center of the group, and the camera will still follow the Target Group’s movement.</p><p>In the example below, the Aim mode is disabled to show only the movement following the center of the object group. This is a common type of camera for fighting games like Super Smash Bros. Note that the camera will not automatically pan or zoom to keep objects in frame, but will simply follow the movement of the position of the center of the objects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iFG-9IhCq7IU9LJe4szOmg.gif" /><figcaption>Target Group Body Transposition Only</figcaption></figure><p>If the Target Group is in the virtual camera’s Look At field and the Aim mode is set to Group Composer, the camera will aim toward the position of the Target Group. The Aim section is very similar to the regular Composer mode but also include a few additional options.</p><p>Group Framing Size sets how much of the screen the group should take up. A lower value will cause the camera to zoom out to keep the objects in frame, while a higher value will cause the camera to zoom in. The Framing Mode allows you to define how you want the objects framed. The Frame Damping sets how quickly the camera should correct its aim.</p><p>The Adjustment Mode gives you the option for the camera to zoom to keep the group in frame, do a dolly movement, or both. If set to zoom or both, you can set the Minimum FOV and Maximum FOV that the camera is allowed to use to zoom. If set to dolly or both, you can set the amount of distance the camera can move toward and away from the focus point using Max Dolly In and Max Dolly Out, and you can set the Minimum Distance and Maximum Distance the camera can be.</p><p>In the example below, the Body mode is disabled to show only the aim following the center of the object group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iKJkdAy1e-du8o5bd0x7bQ.gif" /><figcaption>Target Group Aim Group Composer Only with Zoom Adjustment Mode</figcaption></figure><p>Combining the Body and Aim options gives you a lot of control over how a virtual camera can move and aim in order to keep a group of objects in frame. Setting an accurate Radius and a helpful Weight value for each object allows you to fine-tune the actual center of the object group. And if you experiment with the settings enough, you’re sure to find the perfect camera behavior for your application!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2fCTwgR8T9gwug8WFVKXnA.gif" /><figcaption>Combining Body and Aim Options</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d2adbac434a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>