<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Unity &#8211; MaXEster Technologies  | Technical Blog</title>
	<atom:link href="https://www.maxester.com/blog/tag/unity/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.maxester.com/blog</link>
	<description>Tutorials, Examples and Implementation code for Developers Help</description>
	<lastBuildDate>Mon, 17 Feb 2025 09:17:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.22</generator>
	<item>
		<title>How to make camera follow the player in Unity 3d?</title>
		<link>https://www.maxester.com/blog/2020/02/24/how-do-you-make-the-camera-follow-the-player-in-unity-3d/</link>
		<comments>https://www.maxester.com/blog/2020/02/24/how-do-you-make-the-camera-follow-the-player-in-unity-3d/#comments</comments>
		<pubDate>Mon, 24 Feb 2020 08:07:37 +0000</pubDate>
		<dc:creator><![CDATA[Birjesh Gupta]]></dc:creator>
				<category><![CDATA[Unity]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Unity3D]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=830</guid>
		<description><![CDATA[<p>In this article we will learn about. How do you make the camera follow the player in Unity 3d? And, we&#8217;ll enable the camera to follow the player around the play field by writing a simple C# script. Create a&#8230;</p>
<p><a href="https://www.maxester.com/blog/2020/02/24/how-do-you-make-the-camera-follow-the-player-in-unity-3d/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2020/02/24/how-do-you-make-the-camera-follow-the-player-in-unity-3d/">How to make camera follow the player in Unity 3d?</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p>In this article we will learn about. <strong>How do you make the camera follow the player in Unity 3d?</strong></p>



<p>And, we&#8217;ll enable the camera to follow the player around the play field by writing a simple C# script.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<h3> Create a script for Camera.</h3>



<p>click on Main Camera &#8211;&gt; go to Inspector window &#8211;&gt; click on Add components &#8211;&gt;new Script &#8211;&gt;Name the script(CameraController).</p>



<p><strong>OR</strong></p>



<p>Go to inside the Project Window.</p>



<p>right-click&#8211;&gt; create &#8211;&gt; C# Script </p>



<p>Rename the file as CameraController</p>



<p>Now, paste the following code into your script.</p>



<pre class="wp-block-code"><code>using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour {

    public GameObject player;        //Public variable to store a reference to the player game object


    private Vector3 offset;            //Private variable to store the offset distance between the player and camera

    // Use this for initialization
    void Start () 
    {
        //Calculate and store the offset value by getting the distance between the player's position and camera's position.
        offset = transform.position - player.transform.position;
    }

    // LateUpdate is called after Update each frame
    void LateUpdate () 
    {
        // Set the position of the camera's transform to be the same as the player's, but offset by the calculated offset distance.
        transform.position = player.transform.position + offset;
    }
}</code></pre>



<p>If you were created script  from Project window then drag and drop the script on Main Camera. It will add the script to main Camera.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<figure class="wp-block-image"><img src="https://www.maxester.com/blog/wp-content/uploads/2020/02/Capture.png" alt="" class="wp-image-832" srcset="https://www.maxester.com/blog/wp-content/uploads/2020/02/Capture.png 300w, https://www.maxester.com/blog/wp-content/uploads/2020/02/Capture-145x300.png 145w" sizes="(max-width: 300px) 100vw, 300px" /></figure>



<p>Now, Drag and Drop the Player into Player field inside on CameraController script inside the Main Camera Inspector window.</p>



<p>Now, Run the project and you will get the camera follow the Player movement.</p>



<p>Hope this will be helpfull for  you.</p>



<p>Thank You.</p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2020/02/24/how-do-you-make-the-camera-follow-the-player-in-unity-3d/">How to make camera follow the player in Unity 3d?</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2020/02/24/how-do-you-make-the-camera-follow-the-player-in-unity-3d/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
