<?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>Asteroids Archives - Oxmond Technology</title>
	<atom:link href="https://oxmond.com/tag/asteroids/feed/" rel="self" type="application/rss+xml" />
	<link>https://oxmond.com/tag/asteroids/</link>
	<description>IT Development</description>
	<lastBuildDate>Wed, 18 Nov 2020 04:49:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.2</generator>
	<item>
		<title>How To Build a Video Player With Scrub Control in Unity!</title>
		<link>https://oxmond.com/how-to-build-a-video-player-with-scrub-control-in-unity/</link>
					<comments>https://oxmond.com/how-to-build-a-video-player-with-scrub-control-in-unity/#comments</comments>
		
		<dc:creator><![CDATA[Oxmond Technology]]></dc:creator>
		<pubDate>Fri, 06 Sep 2019 16:11:18 +0000</pubDate>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Unity]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[2019]]></category>
		<category><![CDATA[2D]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[Asteroids]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[building]]></category>
		<category><![CDATA[building a videoplayer]]></category>
		<category><![CDATA[coding pirates]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[controls]]></category>
		<category><![CDATA[engine]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[Hans Oxmond]]></category>
		<category><![CDATA[How To Build a Video Player With Scrub Control in Unity]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[overview]]></category>
		<category><![CDATA[Oxmond Unity Tutorials]]></category>
		<category><![CDATA[pause]]></category>
		<category><![CDATA[play]]></category>
		<category><![CDATA[playback]]></category>
		<category><![CDATA[player]]></category>
		<category><![CDATA[scrub]]></category>
		<category><![CDATA[scrub control for unity video player]]></category>
		<category><![CDATA[scrubbing]]></category>
		<category><![CDATA[seek]]></category>
		<category><![CDATA[seek with video player]]></category>
		<category><![CDATA[streaming]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[ui]]></category>
		<category><![CDATA[Unity3d]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[video controls]]></category>
		<category><![CDATA[video pause]]></category>
		<category><![CDATA[video player]]></category>
		<category><![CDATA[video player controls]]></category>
		<category><![CDATA[video ui]]></category>
		<category><![CDATA[videoplayer]]></category>
		<category><![CDATA[videoplayer control]]></category>
		<guid isPermaLink="false">https://oxmond.com/?p=591</guid>

					<description><![CDATA[<p>In this tutorial we build our own video player. Complete with play &#38; pause buttons and a nice scrub bar controller. What&#8217;s not to like? 😛 ✅ Download the files and scripts from the tutorial here: oxmond.com/download/tutorials/unity/Oxmond_videoplayer.unitypackage ✅ Download free assets from the Unity Assets...</p>
<p>The post <a rel="nofollow" href="https://oxmond.com/how-to-build-a-video-player-with-scrub-control-in-unity/">How To Build a Video Player With Scrub Control in Unity!</a> appeared first on <a rel="nofollow" href="https://oxmond.com">Oxmond Technology</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In this tutorial we build our own video player. Complete with play &amp; pause buttons and a nice scrub bar controller. What&#8217;s not to like? 😛</p>
<hr />
<p>✅ <strong>Download the files and scripts from the tutorial here:<br />
</strong><a href="https://oxmond.com/download/tutorials/unity/Oxmond_videoplayer.unitypackage" target="_blank" rel="noopener noreferrer">oxmond.com/download/tutorials/unity/Oxmond_videoplayer.unitypackage</a></p>
<hr />
<p>✅ <strong>Download free assets from the Unity Assets Store:</strong><br />
<a href="https://assetstore.unity.com/lists/top-free-packages-13201?aid=1100l4p9k" target="_blank" rel="noopener noreferrer">https://assetstore.unity.com/lists/top-free-packages-13201?aid=1100l4p9k</a></p>
<hr />
<p>❤️ <strong>Subscribe to Oxmond Tutorials. Stay ahead of the game!</strong><br />
<a href="https://bit.ly/SubscribeOxmondTutorials">https://bit.ly/SubscribeOxmondTutorials</a></p>
<hr />
<p>😷👕 <strong>Need a face mask / developer T-shirt? Drop by our shop and get a 20% DISCOUNT on your first purchase by using the discount code OXMONDSALE. Click here:</strong><br />
<a href="https://shop.oxmond.com/discount/OXMONDSALE">https://shop.oxmond.com/discount/OXMONDSALE</a></p>
<hr />
<p><strong>MyVideoPlayer script:</strong></p>
<pre>/*

   .-------.                             .--.    .-------.     .--.            .--.     .--.        
   |       |--.--.--------.-----.-----.--|  |    |_     _|--.--|  |_.-----.----|__|---.-|  |-----.
   |   -   |_   _|        |  _  |     |  _  |      |   | |  |  |   _|  _  |   _|  |  _  |  |__ --|
   |_______|__.__|__|__|__|_____|__|__|_____|      |___| |_____|____|_____|__| |__|___._|__|_____|
   © 2019 OXMOND / www.oxmond.com 

*/

using UnityEngine;
using UnityEngine.Video;
using System.Collections;

public class MyVideoPlayer : MonoBehaviour
{

    public GameObject cinemaPlane;
    public GameObject btnPlay;
    public GameObject btnPause;
    public GameObject knob;
    public GameObject progressBar;
    public GameObject progressBarBG;

    private float maxKnobValue;
    private float newKnobX;
    private float maxKnobX;
    private float minKnobX;
    private float knobPosY;
    private float simpleKnobValue;
    private float knobValue;
    private float progressBarWidth;
    private bool knobIsDragging;
    private bool videoIsJumping = false;
    private bool videoIsPlaying = false;
    private VideoPlayer videoPlayer;
    
    private void Start  ()
    {
        knobPosY = knob.transform.localPosition.y;
        videoPlayer = GetComponent();
        btnPause.SetActive(true);
        btnPlay.SetActive(false);
        videoPlayer.frame = (long)100;
        progressBarWidth = progressBarBG.GetComponent().bounds.size.x;
    }

    private void Update()
    {
        if (!knobIsDragging &amp;&amp; !videoIsJumping)
        {
            if (videoPlayer.frameCount &gt; 0)
            {
                float progress = (float)videoPlayer.frame / (float)videoPlayer.frameCount;
                progressBar.transform.localScale = new Vector3(progressBarWidth * progress, progressBar.transform.localScale.y, 0);
                knob.transform.localPosition = new Vector2(progressBar.transform.localPosition.x + (progressBarWidth * progress), knob.transform.localPosition.y);
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            Vector3 pos = Input.mousePosition;
            Collider2D hitCollider = Physics2D.OverlapPoint(Camera.main.ScreenToWorldPoint(pos));
            
            if (hitCollider != null &amp;&amp; hitCollider.CompareTag(btnPause.tag))
            {
                BtnPlayVideo();
            }
            if (hitCollider != null &amp;&amp; hitCollider.CompareTag(btnPlay.tag))
            {
                print("playBtn");
                BtnPlayVideo();
            }
        }
    }

    public void KnobOnPressDown()
    {
        VideoStop();
        minKnobX = progressBar.transform.localPosition.x;
        maxKnobX = minKnobX + progressBarWidth;
    }

    public void KnobOnRelease()
    {
        knobIsDragging = false;
        CalcKnobSimpleValue();
        VideoPlay();
        VideoJump();
        StartCoroutine(DelayedSetVideoIsJumpingToFalse());
    }

    IEnumerator DelayedSetVideoIsJumpingToFalse()
    {
        yield return new WaitForSeconds(2);
        SetVideoIsJumpingToFalse();
    }

    public void KnobOnDrag()
    {
        knobIsDragging = true;
        videoIsJumping = true;
        Vector3 curScreenPoint = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
        Vector3 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint);
        knob.transform.position = new Vector2(curPosition.x, curPosition.y);
        newKnobX = knob.transform.localPosition.x;
        if (newKnobX &gt; maxKnobX) { newKnobX = maxKnobX; }
        if (newKnobX &lt; minKnobX) { newKnobX = minKnobX; }
        knob.transform.localPosition = new Vector2(newKnobX, knobPosY);
        CalcKnobSimpleValue();
        progressBar.transform.localScale = new Vector3(simpleKnobValue * progressBarWidth, progressBar.transform.localScale.y, 0);
    }

    private void SetVideoIsJumpingToFalse()
    {
        videoIsJumping = false;
    }

    private void CalcKnobSimpleValue()
    {
        maxKnobValue = maxKnobX - minKnobX;
        knobValue = knob.transform.localPosition.x - minKnobX;
        simpleKnobValue = knobValue / maxKnobValue;
    }

    private void VideoJump()
    {
        var frame = videoPlayer.frameCount * simpleKnobValue;
        videoPlayer.frame = (long)frame;
    }

    private void BtnPlayVideo()
    {
        if (videoIsPlaying)
        {
            VideoStop();
        }
        else
        {
            VideoPlay();
        }
    }

    private void VideoStop()
    {
        videoIsPlaying = false;
        videoPlayer.Pause();
        btnPause.SetActive(false);
        btnPlay.SetActive(true);
    }

    private void VideoPlay()
    {
        videoIsPlaying = true;
        videoPlayer.Play();
        btnPause.SetActive(true);
        btnPlay.SetActive(false);
    }
}
</pre>
<hr />
<p><strong>The Knob Script:</strong></p>
<pre>using UnityEngine;

// [RequireComponent(typeof(MeshCollider))]
/*

   .-------.                             .--.    .-------.     .--.            .--.     .--.        
   |       |--.--.--------.-----.-----.--|  |    |_     _|--.--|  |_.-----.----|__|---.-|  |-----.
   |   -   |_   _|        |  _  |     |  _  |      |   | |  |  |   _|  _  |   _|  |  _  |  |__ --|
   |_______|__.__|__|__|__|_____|__|__|_____|      |___| |_____|____|_____|__| |__|___._|__|_____|
   © 2019 OXMOND / www.oxmond.com 

*/

public class Knob : MonoBehaviour
{
    public GameObject videoPlayer;
    private MyVideoPlayer videoPlayerScript;

    void Start()
    {
        videoPlayerScript = videoPlayer.GetComponent();
    }

    void OnMouseDown()
    {
        videoPlayerScript.KnobOnPressDown();
    }

    void OnMouseUp()
    {
        videoPlayerScript.KnobOnRelease();
    }

    void OnMouseDrag()
    {
        videoPlayerScript.KnobOnDrag();
    }

}

</pre>
<p>The post <a rel="nofollow" href="https://oxmond.com/how-to-build-a-video-player-with-scrub-control-in-unity/">How To Build a Video Player With Scrub Control in Unity!</a> appeared first on <a rel="nofollow" href="https://oxmond.com">Oxmond Technology</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://oxmond.com/how-to-build-a-video-player-with-scrub-control-in-unity/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>How to Create the Iconic Asteroids Arcade Gameplay! Unity 2019 Intermediate Tutorial</title>
		<link>https://oxmond.com/asteroids-arcade-gameplay/</link>
					<comments>https://oxmond.com/asteroids-arcade-gameplay/#comments</comments>
		
		<dc:creator><![CDATA[Oxmond Technology]]></dc:creator>
		<pubDate>Mon, 13 May 2019 10:07:34 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[2019]]></category>
		<category><![CDATA[2D]]></category>
		<category><![CDATA[Asteroids]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[coding pirates]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[gameplay]]></category>
		<category><![CDATA[lesson]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[skybox]]></category>
		<category><![CDATA[star]]></category>
		<category><![CDATA[stars]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[Unity]]></category>
		<category><![CDATA[Unity3d]]></category>
		<guid isPermaLink="false">https://oxmond.com/?p=445</guid>

					<description><![CDATA[<p>Learn how to setup and code the iconic Asteroids shooter arcade gameplay originally designed by Lyle Rains &#38; Ed Logg and released by Atari in 1979. ···················································································· ❤️ Subscribe to Oxmond Tutorials https://bit.ly/SubscribeOxmondTutorials 🚀 Play the game here: https://oxmond.com/games/asteroids/ ✅ Download the free star skybox here...</p>
<p>The post <a rel="nofollow" href="https://oxmond.com/asteroids-arcade-gameplay/">How to Create the Iconic Asteroids Arcade Gameplay! Unity 2019 Intermediate Tutorial</a> appeared first on <a rel="nofollow" href="https://oxmond.com">Oxmond Technology</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Learn how to setup and code the iconic Asteroids shooter arcade gameplay originally designed by Lyle Rains &amp; Ed Logg and released by Atari in 1979.</p>
<p>····················································································</p>
<p>❤️ <strong>Subscribe to Oxmond Tutorials</strong><br />
<a href="https://bit.ly/SubscribeOxmondTutorials">https://bit.ly/SubscribeOxmondTutorials</a></p>
<p><strong>🚀 Play the game here:</strong><br />
<a href="https://oxmond.com/games/asteroids/">https://oxmond.com/games/asteroids/</a></p>
<p>✅<strong> Download the free star skybox here (Real Stars Skybox):</strong><br />
<a href="https://assetstore.unity.com/packages/3d/environments/sci-fi/real-stars-skybox-116333?aid=1100l4p9k">https://assetstore.unity.com/packages/3d/environments/sci-fi/real-stars-skybox-116333?aid=1100l4p9k</a></p>
<p>✅<strong> Download Yughues Free Rocks here:</strong><br />
<a href="https://assetstore.unity.com/packages/3d/environments/yughues-free-rocks-13568?aid=1100l4p9k">https://assetstore.unity.com/packages/3d/environments/yughues-free-rocks-13568?aid=1100l4p9k</a></p>
<p>✅ <strong>Download the Rocket mesh here:</strong><br />
<a href="https://assetstore.unity.com/packages/3d/vehicles/space/atom-rocket-model-140021?aid=1100l4p9k">https://assetstore.unity.com/packages/3d/vehicles/space/atom-rocket-model-140021?aid=1100l4p9k</a></p>
<p>✅ <strong>Other free Asset Packages at the Unity Assets Store:</strong><br />
<a href="https://assetstore.unity.com/lists/top-free-packages-13201?aid=1100l4p9k">https://assetstore.unity.com/lists/top-free-packages-13201?aid=1100l4p9k</a></p>
<p>😷👕 <strong>Need a face mask / developer T-shirt? Drop by our shop and get a 20% DISCOUNT on your first purchase by using the discount code OXMONDSALE. Click here:</strong><br />
<a href="https://shop.oxmond.com/discount/OXMONDSALE">https://shop.oxmond.com/discount/OXMONDSALE</a></p>
<hr />
<p><strong>Asteroid.cs</strong></p>
<pre>/*

   .-------.                             .--.    .-------.     .--.            .--.     .--.        
   |       |--.--.--------.-----.-----.--|  |    |_     _|--.--|  |_.-----.----|__|---.-|  |-----.
   |   -   |_   _|        |  _  |     |  _  |      |   | |  |  |   _|  _  |   _|  |  _  |  |__ --|
   |_______|__.__|__|__|__|_____|__|__|_____|      |___| |_____|____|_____|__| |__|___._|__|_____|
   © OXMOND / www.oxmond.com 

*/

using UnityEngine;

public class Asteroid : MonoBehaviour
{

    public GameObject rock;
    public Gameplay gameplay;
    private float maxRotation;
    private float rotationX;
    private float rotationY;
    private float rotationZ;
    private Rigidbody rb;
    private Camera mainCam;
    private float maxSpeed;
    private int _generation;

    void Start()
    {

        mainCam = Camera.main;

        maxRotation = 25f;
        rotationX = Random.Range(-maxRotation, maxRotation);
        rotationY = Random.Range(-maxRotation, maxRotation);
        rotationZ = Random.Range(-maxRotation, maxRotation);

        rb = rock.GetComponent();

        float speedX = Random.Range(200f, 800f);
        int selectorX = Random.Range(0, 2);
        float dirX = 0;
        if (selectorX == 1) { dirX = -1; }
        else { dirX = 1; }
        float finalSpeedX = speedX * dirX;
        rb.AddForce(transform.right * finalSpeedX);

        float speedY = Random.Range(200f, 800f);
        int selectorY = Random.Range(0, 2);
        float dirY = 0;
        if (selectorY == 1) { dirY = -1; }
        else { dirY = 1; }
        float finalSpeedY = speedY * dirY;
        rb.AddForce(transform.up * finalSpeedY);

    }

    public void SetGeneration(int generation)
    {
        _generation = generation;
    }

    void Update()
    {
        rock.transform.Rotate(new Vector3(rotationX, rotationY, 0) * Time.deltaTime);
        CheckPosition();
        float dynamicMaxSpeed = 3f;
        rb.velocity = new Vector2(Mathf.Clamp(rb.velocity.x, -dynamicMaxSpeed, dynamicMaxSpeed), Mathf.Clamp(rb.velocity.y, -dynamicMaxSpeed, dynamicMaxSpeed));
    }

    void OnCollisionEnter(Collision collisionInfo)
    {
        if (collisionInfo.collider.name == "Bullet(Clone)")
        {
            if (_generation &lt; 3)
            {
                CreateSmallAsteriods(2);
            }
            Destroy();
        }

        if (collisionInfo.collider.name == "Rocket")
        {
            gameplay.RocketFail();
        }
    }

    void CreateSmallAsteriods(int asteroidsNum)
    {
        int newGeneration = _generation + 1;
        for (int i = 1; i &lt;= asteroidsNum; i++)
        {
            float scaleSize = 0.5f;
            GameObject AsteroidClone = Instantiate(rock, new Vector3(transform.position.x, transform.position.y, 0f), transform.rotation);
            AsteroidClone.transform.localScale = new Vector3(AsteroidClone.transform.localScale.x * scaleSize, AsteroidClone.transform.localScale.y * scaleSize, AsteroidClone.transform.localScale.z * scaleSize);
            AsteroidClone.GetComponent().SetGeneration(newGeneration);
            AsteroidClone.SetActive(true);
        }
    }

    private void CheckPosition()
    {

        float sceneWidth = mainCam.orthographicSize * 2 * mainCam.aspect;
        float sceneHeight = mainCam.orthographicSize * 2;
        float sceneRightEdge = sceneWidth / 2;
        float sceneLeftEdge = sceneRightEdge * -1;
        float sceneTopEdge = sceneHeight / 2;
        float sceneBottomEdge = sceneTopEdge * -1;

        float rockOffset;
        if (gameplay.allAsteroidsOffScreen)
        {
            rockOffset = 1.0f;
            float reverseSpeed = 2000.1f;

            if (rock.transform.position.x &gt; sceneRightEdge + rockOffset)
            {
                rock.transform.rotation = Quaternion.identity;
                rb.AddForce(transform.right * (reverseSpeed * (-1)));
            }

            if (rock.transform.position.x &lt; sceneLeftEdge - rockOffset) { rock.transform.rotation = Quaternion.identity; rb.AddForce(transform.right * reverseSpeed); } if (rock.transform.position.y &gt; sceneTopEdge + rockOffset)
            {
                rock.transform.rotation = Quaternion.identity;
                rb.AddForce(transform.up * (reverseSpeed * (-1)));
            }

            if (rock.transform.position.y &lt; sceneBottomEdge - rockOffset) { rock.transform.rotation = Quaternion.identity; rb.AddForce(transform.up * reverseSpeed); } } else { rockOffset = 2.0f; if (rock.transform.position.x &gt; sceneRightEdge + rockOffset)
            {
                rock.transform.position = new Vector2(sceneLeftEdge - rockOffset, rock.transform.position.y);
            }

            if (rock.transform.position.x &lt; sceneLeftEdge - rockOffset) { rock.transform.position = new Vector2(sceneRightEdge + rockOffset, rock.transform.position.y); } if (rock.transform.position.y &gt; sceneTopEdge + rockOffset)
            {
                rock.transform.position = new Vector2(rock.transform.position.x, sceneBottomEdge - rockOffset);
            }

            if (rock.transform.position.y &lt; sceneBottomEdge - rockOffset)
            {
                rock.transform.position = new Vector2(rock.transform.position.x, sceneTopEdge + rockOffset);
            }
        }
    }

    public void Destroy()
    {
        gameplay.asterodDestroyed();
        Destroy(gameObject, 0.01f);
    }

    public void DestroySilent()
    {
        Destroy(gameObject, 0.00f);
    }

}

</pre>
<p><strong>Bullet.cs</strong></p>
<pre>
/*

   .-------.                             .--.    .-------.     .--.            .--.     .--.        
   |       |--.--.--------.-----.-----.--|  |    |_     _|--.--|  |_.-----.----|__|---.-|  |-----.
   |   -   |_   _|        |  _  |     |  _  |      |   | |  |  |   _|  _  |   _|  |  _  |  |__ --|
   |_______|__.__|__|__|__|_____|__|__|_____|      |___| |_____|____|_____|__| |__|___._|__|_____|
   © OXMOND / www.oxmond.com 

*/

using UnityEngine;

public class Bullet : MonoBehaviour
{
    void Start()
    {
        GetComponent().AddForce(transform.up * 350);
    }

    public void KillOldBullet()
    {
        Destroy(gameObject, 2.0f);
    }

    void OnCollisionEnter(Collision collisionInfo)
    {
        Destroy(gameObject, 0.0f);
    }
}

</pre>
<p>
<strong>Gameplay.cs</strong></p>
<pre>/*

   .-------.                             .--.    .-------.     .--.            .--.     .--.        
   |       |--.--.--------.-----.-----.--|  |    |_     _|--.--|  |_.-----.----|__|---.-|  |-----.
   |   -   |_   _|        |  _  |     |  _  |      |   | |  |  |   _|  _  |   _|  |  _  |  |__ --|
   |_______|__.__|__|__|__|_____|__|__|_____|      |___| |_____|____|_____|__| |__|___._|__|_____|
   © OXMOND / www.oxmond.com 

*/

using UnityEngine;

public class Gameplay : MonoBehaviour
{

    public GameObject asteroid;
    public GameObject rocket;
    private int _startLevelAsteroidsNum;
    private bool _allAsteroidsOffScreen;
    private int levelAsteroidNum;
    private Camera mainCam;
    private int asteroidLife;

    private void Start()
    {
        asteroid.SetActive(false);
        mainCam = Camera.main;
        _startLevelAsteroidsNum = 2;
        CreateAsteroids(_startLevelAsteroidsNum);
    }

    private void Update()
    {
        RenderSettings.skybox.SetFloat("_Rotation", Time.time * 0.8f);

        if (asteroidLife &lt;= 0)
        {
            asteroidLife = 6;
            CreateAsteroids(1);
        }
        
        float sceneWidth = mainCam.orthographicSize * 2 * mainCam.aspect;
        float sceneHeight = mainCam.orthographicSize * 2;
        float sceneRightEdge = sceneWidth / 2;
        float sceneLeftEdge = sceneRightEdge * -1;
        float sceneTopEdge = sceneHeight / 2;
        float sceneBottomEdge = sceneTopEdge * -1;

        _allAsteroidsOffScreen = true;
        
    }

    private void CreateAsteroids(float asteroidsNum)
    {
        for (int i = 1; i &lt;= asteroidsNum; i++)
        {
            GameObject AsteroidClone = Instantiate(asteroid, new Vector2(Random.Range(-10, 10), 6f), transform.rotation);
            AsteroidClone.GetComponent().SetGeneration(1);
            AsteroidClone.SetActive(true);
        }
    }

    public void RocketFail()
    {
        Cursor.visible = true;
        print("GAME OVER");
    }

    public void asterodDestroyed()
    {
        asteroidLife--;
    }

    public int startLevelAsteroidsNum
    {
        get { return _startLevelAsteroidsNum; }
    }

    public bool allAsteroidsOffScreen
    {
        get { return _allAsteroidsOffScreen; }
    }

}</pre>
<hr />
<p>
<strong>Rocket.cs</strong></p>
<pre>/*

   .-------.                             .--.    .-------.     .--.            .--.     .--.        
   |       |--.--.--------.-----.-----.--|  |    |_     _|--.--|  |_.-----.----|__|---.-|  |-----.
   |   -   |_   _|        |  _  |     |  _  |      |   | |  |  |   _|  _  |   _|  |  _  |  |__ --|
   |_______|__.__|__|__|__|_____|__|__|_____|      |___| |_____|____|_____|__| |__|___._|__|_____|
   © OXMOND / www.oxmond.com 

*/

using UnityEngine;

public class Rocket : MonoBehaviour
{
    public GameObject bullet;
    private float thrust = 6f;
    private float rotationSpeed = 180f;
    private float MaxSpeed = 4.5f;
    private Camera mainCam;
    private Rigidbody rb;

    private void Start()
    {
        mainCam = Camera.main;
        rb = GetComponent();
        bullet.SetActive(false);
    }

    private void FixedUpdate()
    {
        ControlRocket();
        CheckPosition();
    }

    private void Update()
    {
        if (Input.GetMouseButtonDown(0) || Input.GetKeyDown("space"))
        {
            Shoot();
        }
    }

    private void ControlRocket()
    {
        transform.Rotate(0, 0, Input.GetAxis("Horizontal") * rotationSpeed * Time.deltaTime);
        rb.AddForce(transform.up * thrust * Input.GetAxis("Vertical"));
        rb.velocity = new Vector2(Mathf.Clamp(rb.velocity.x, -MaxSpeed, MaxSpeed), Mathf.Clamp(rb.velocity.y, -MaxSpeed, MaxSpeed));
    }

    private void CheckPosition()
    {

        float sceneWidth = mainCam.orthographicSize * 2 * mainCam.aspect;
        float sceneHeight = mainCam.orthographicSize * 2;

        float sceneRightEdge = sceneWidth / 2;
        float sceneLeftEdge = sceneRightEdge * -1;
        float sceneTopEdge = sceneHeight / 2;
        float sceneBottomEdge = sceneTopEdge * -1;

        if (transform.position.x &gt; sceneRightEdge)
        {
            transform.position = new Vector2(sceneLeftEdge, transform.position.y);
        }
        if (transform.position.x &lt; sceneLeftEdge) { transform.position = new Vector2(sceneRightEdge, transform.position.y); } if (transform.position.y &gt; sceneTopEdge)
        {
            transform.position = new Vector2(transform.position.x, sceneBottomEdge);
        }
        if (transform.position.y &lt; sceneBottomEdge)
        {
            transform.position = new Vector2(transform.position.x, sceneTopEdge);
        }
    }

    public void ResetRocket()
    {
        transform.position = new Vector2(0f, 0f);
        transform.eulerAngles = new Vector3(0, 180f, 0);
        rb.velocity = new Vector3(0f, 0f, 0f);
        rb.angularVelocity = new Vector3(0f, 0f, 0f);
    }

    void Shoot()
    {
            GameObject BulletClone = Instantiate(bullet, new Vector2(bullet.transform.position.x, bullet.transform.position.y), transform.rotation);
            BulletClone.SetActive(true);
            BulletClone.GetComponent().KillOldBullet();
            BulletClone.GetComponent().AddForce(transform.up * 350);
    }
}

</pre>
<p>The post <a rel="nofollow" href="https://oxmond.com/asteroids-arcade-gameplay/">How to Create the Iconic Asteroids Arcade Gameplay! Unity 2019 Intermediate Tutorial</a> appeared first on <a rel="nofollow" href="https://oxmond.com">Oxmond Technology</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://oxmond.com/asteroids-arcade-gameplay/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
	</channel>
</rss>
