Thursday 20 December 2018

Unity 2D Enemy AI Platformer Tutorial (Hindi/Urdu) [07]







Tutorials will be in both English and Hindi Audio.

Check my channel for my videos.

#2D #Platformer

A complete video tutorial series on Unity Game development

for beginners.Suitable for beginners and intermediate programmers.

Kitty Vs Max is a 2d platformer game build with unity for android and ios mobile phones.



Hindi Version Playlist

https://www.youtube.com/playlist?list=PLgAF6rpCsTCgsuXBNPZOsNcnhLzStYfx-



English Version Playlist

https://www.youtube.com/playlist?list=PLgAF6rpCsTCj9c3__jGQCYgtfQFj1TCoB



============ Please Like the video =========

Download The Assets:

https://goo.gl/uvaYo4



Watch Other Amazing Videos

https://goo.gl/8vQJ39



Join WhatsApp Group

https://chat.whatsapp.com/invite/9qAQ373cPryFwgtvtl8b8q



Join FaceBook Group

https://www.facebook.com/groups/1768194436812852

Sunday 16 December 2018

Unity 2D Platformer - Enemy AI - [kitty vs max] 05






Tutorials will be in both English and Hindi Audio.
Check my channel for my videos.
#2D #Platformer
A complete video tutorial series on Unity Game development
for beginners.Suitable for beginners and intermediate programmers.
Kitty Vs Max is a 2d platformer game build with unity for android and ios mobile phones.

Hindi Version Playlist
https://www.youtube.com/playlist?list=PLgAF6rpCsTCgsuXBNPZOsNcnhLzStYfx-

English Version Playlist
https://www.youtube.com/playlist?list=PLgAF6rpCsTCj9c3__jGQCYgtfQFj1TCoB

============ Please Like the video =========
Download The Assets:
https://goo.gl/uvaYo4

Watch Other Amazing Videos
https://goo.gl/8vQJ39

Join WhatsApp Group
https://chat.whatsapp.com/invite/9qAQ373cPryFwgtvtl8b8q

Join FaceBook Group
https://www.facebook.com/groups/1768194436812852

Tuesday 11 December 2018

Unity 2D Platformer Game Tutorial in Hindi - [smooth gameplay 04 ]





Tutorials will be in both English and Hindi Audio.

Check my channel for my videos.

#2D #Platformer

A complete video tutorial series on Unity Game development

for beginners.Suitable for beginners and intermediate programmers.

Kitty Vs Max is a 2d platformer game build with unity for android and ios mobile phones.



Hindi Version Playlist

https://www.youtube.com/playlist?list=PLgAF6rpCsTCgsuXBNPZOsNcnhLzStYfx-



English Version Playlist

https://www.youtube.com/playlist?list=PLgAF6rpCsTCj9c3__jGQCYgtfQFj1TCoB

Saturday 21 July 2018

Unity Count Down Timer with circular progressbar

Watch Video Tutorial On My Channel

Assets:



White Dotted image is here

Script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Loading : MonoBehaviour {

public Image loading;
public Text timeText;
public int minutes;
public int sec;
int totalSeconds = 0;
int TOTAL_SECONDS = 0;
float fillamount;

void Start ()
{
timeText.text = minutes + " : " + sec;
if (minutes > 0)
totalSeconds += minutes * 60;
if (sec > 0)
totalSeconds += sec;
TOTAL_SECONDS = totalSeconds;
StartCoroutine (second ());
}

void Update ()
{
if (sec == 0 && minutes == 0) {
timeText.text = "Time's Up!";
StopCoroutine (second ());
}
}
IEnumerator second()
{
yield return new WaitForSeconds (1f);
if(sec > 0)
sec--;
if (sec == 0 && minutes != 0) {
sec = 60;
minutes--;
timeText.text = minutes + " : " + sec;
fillLoading ();
StartCoroutine (second ());
}

void fillLoading()
{
totalSeconds--;
float fill = (float)totalSeconds/TOTAL_SECONDS;
loading.fillAmount = fill;
}
}

Sunday 15 July 2018

How to Make a Wheel of Fortune in Unity 2018 [ free code + assets ]

Watch Video Tutorial On Youtube

Spinner Script


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class spinner : MonoBehaviour {

public float reducer;
public float multiplier = 1;
bool round1 = false;
public bool isStoped = false;


void Start ()
{
reducer = Random.Range (0.01f, 0.5f);
}
// Update is called once per frameQ
void FixedUpdate () {

if (Input.GetKey (KeyCode.Space)) 
{
Reset ();
}

if (multiplier > 0)
{
transform.Rotate (Vector3.forward, 1 * multiplier);
} else
{
isStoped = true;
}

if (multiplier < 20 && !round1) 
{
multiplier += 0.1f;
} else 
{
round1 = true;
}

if (round1 && multiplier > 0)
{
multiplier -= reducer;
}


void Reset()
{
multiplier = 1;
reducer = Random.Range (0.01f, 0.5f);
round1 = false;
isStoped = false;
}
}

Needle Script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class needle : MonoBehaviour {
public spinner _spinner;
public Text scoretext;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}

void OnTriggerStay2D(Collider2D col){
if (!_spinner.isStoped)
return;
scoretext.text = col.gameObject.name;

}

}

Saturday 7 July 2018

Unity 3d Play sound on trigger and particle effect [HINDI/URDU]



unity 3d play sound on Trigger c# and particle system tutorial.

in this video  i will show you how to play win sound when player reaches a finish point or stage is cleared in hindi urdu.

Thursday 17 May 2018

how to use slider in unity


first goto -> create -> UI -> slider and create a slider this will create a canvas if not already created.
create a script and attach it to any gameobject (payer or camera) or just put the code in any script
assing the public slider variable in inspector by draging the slider component from hierarchy to inspector as shown below.

now run the code after running you will notice the slider value will change to 10 as written in code.

Monday 19 March 2018

unity 2d shooter game tutorial (Shooting A bullete) 04




unity 2d shooter game tutorial.
how to create a 2d shooting game in unity for android. best 2d game tutorial for android. how to make games like zombie shooting 2. best YouTube channel to learn unity in Hindi Urdu.

Sunday 4 March 2018

FPS SHOOTER (FirstPersonController)

using System;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
using UnityStandardAssets.Utility;
using Random = UnityEngine.Random;

namespace UnityStandardAssets.Characters.FirstPerson
{
    [RequireComponent(typeof (CharacterController))]
    [RequireComponent(typeof (AudioSource))]
    public class FirstPersonController : MonoBehaviour
    {
        [SerializeField] private bool m_IsWalking;
        [SerializeField] private float m_WalkSpeed;
        [SerializeField] private float m_RunSpeed;
        [SerializeField] [Range(0f, 1f)] private float m_RunstepLenghten;
        [SerializeField] private float m_JumpSpeed;
        [SerializeField] private float m_StickToGroundForce;
        [SerializeField] private float m_GravityMultiplier;
        [SerializeField] private MouseLook m_MouseLook;
        [SerializeField] private bool m_UseFovKick;
        [SerializeField] private FOVKick m_FovKick = new FOVKick();
        [SerializeField] private bool m_UseHeadBob;
        [SerializeField] private CurveControlledBob m_HeadBob = new CurveControlledBob();
        [SerializeField] private LerpControlledBob m_JumpBob = new LerpControlledBob();
        [SerializeField] private float m_StepInterval;
        [SerializeField] private AudioClip[] m_FootstepSounds;    // an array of footstep sounds that will be randomly selected from.
        [SerializeField] private AudioClip m_JumpSound;           // the sound played when character leaves the ground.
        [SerializeField] private AudioClip m_LandSound;           // the sound played when character touches back on ground.

        float horizontal;
        float vertical;
        bool walkforward;

        private Camera m_Camera;
        private bool m_Jump;
        private float m_YRotation;
        private Vector2 m_Input;
        private Vector3 m_MoveDir = Vector3.zero;
        private CharacterController m_CharacterController;
        private CollisionFlags m_CollisionFlags;
        private bool m_PreviouslyGrounded;
        private Vector3 m_OriginalCameraPosition;
        private float m_StepCycle;
        private float m_NextStep;
        private bool m_Jumping;
        private AudioSource m_AudioSource;

        // Use this for initialization
        private void Start()
        {
            m_CharacterController = GetComponent<CharacterController>();
            m_Camera = Camera.main;
            m_OriginalCameraPosition = m_Camera.transform.localPosition;
            m_FovKick.Setup(m_Camera);
            m_HeadBob.Setup(m_Camera, m_StepInterval);
            m_StepCycle = 0f;
            m_NextStep = m_StepCycle/2f;
            m_Jumping = false;
            m_AudioSource = GetComponent<AudioSource>();
            m_MouseLook.Init(transform , m_Camera.transform);
        }


        // Update is called once per frame
        private void Update()
        {
            RotateView();
            // the jump state needs to read here to make sure it is not missed
            if (!m_Jump)
            {
                m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
            }

            if (!m_PreviouslyGrounded && m_CharacterController.isGrounded)
            {
                StartCoroutine(m_JumpBob.DoBobCycle());
                PlayLandingSound();
                m_MoveDir.y = 0f;
                m_Jumping = false;
            }
            if (!m_CharacterController.isGrounded && !m_Jumping && m_PreviouslyGrounded)
            {
                m_MoveDir.y = 0f;
            }

            m_PreviouslyGrounded = m_CharacterController.isGrounded;
        }


        private void PlayLandingSound()
        {
            m_AudioSource.clip = m_LandSound;
            m_AudioSource.Play();
            m_NextStep = m_StepCycle + .5f;
        }


        private void FixedUpdate()
        {
            float speed;
            GetInput(out speed);
            // always move along the camera forward as it is the direction that it being aimed at
            Vector3 desiredMove = transform.forward*m_Input.y + transform.right*m_Input.x;

            // get a normal for the surface that is being touched to move along it
            RaycastHit hitInfo;
            Physics.SphereCast(transform.position, m_CharacterController.radius, Vector3.down, out hitInfo,
                               m_CharacterController.height/2f, Physics.AllLayers, QueryTriggerInteraction.Ignore);
            desiredMove = Vector3.ProjectOnPlane(desiredMove, hitInfo.normal).normalized;

            m_MoveDir.x = desiredMove.x*speed;
            Camera.main.transform.Rotate(new Vector3(0.0f, m_MoveDir.x, 0.0f));
           // transform.Rotate(new Vector3(0.0f, m_MoveDir.x,0.0f));
            m_MoveDir.z = desiredMove.z*speed;


            if (m_CharacterController.isGrounded)
            {
                m_MoveDir.y = -m_StickToGroundForce;

                if (m_Jump)
                {
                    m_MoveDir.y = m_JumpSpeed;
                    PlayJumpSound();
                    m_Jump = false;
                    m_Jumping = true;
                }
            }
            else
            {
                m_MoveDir += Physics.gravity*m_GravityMultiplier*Time.fixedDeltaTime;
            }
            m_CollisionFlags = m_CharacterController.Move(m_MoveDir*Time.fixedDeltaTime);

            ProgressStepCycle(speed);
            UpdateCameraPosition(speed);

            m_MouseLook.UpdateCursorLock();
        }


        private void PlayJumpSound()
        {
            m_AudioSource.clip = m_JumpSound;
            m_AudioSource.Play();
        }


        private void ProgressStepCycle(float speed)
        {
            if (m_CharacterController.velocity.sqrMagnitude > 0 && (m_Input.x != 0 || m_Input.y != 0))
            {
                m_StepCycle += (m_CharacterController.velocity.magnitude + (speed*(m_IsWalking ? 1f : m_RunstepLenghten)))*
                             Time.fixedDeltaTime;
            }

            if (!(m_StepCycle > m_NextStep))
            {
                return;
            }

            m_NextStep = m_StepCycle + m_StepInterval;

            PlayFootStepAudio();
        }


        private void PlayFootStepAudio()
        {
            if (!m_CharacterController.isGrounded)
            {
                return;
            }
            // pick & play a random footstep sound from the array,
            // excluding sound at index 0
            int n = Random.Range(1, m_FootstepSounds.Length);
            m_AudioSource.clip = m_FootstepSounds[n];
            m_AudioSource.PlayOneShot(m_AudioSource.clip);
            // move picked sound to index 0 so it's not picked next time
            m_FootstepSounds[n] = m_FootstepSounds[0];
            m_FootstepSounds[0] = m_AudioSource.clip;
        }


        private void UpdateCameraPosition(float speed)
        {
            Vector3 newCameraPosition;
            if (!m_UseHeadBob)
            {
                return;
            }
            if (m_CharacterController.velocity.magnitude > 0 && m_CharacterController.isGrounded)
            {
                m_Camera.transform.localPosition =
                    m_HeadBob.DoHeadBob(m_CharacterController.velocity.magnitude +
                                      (speed*(m_IsWalking ? 1f : m_RunstepLenghten)));
                newCameraPosition = m_Camera.transform.localPosition;
                newCameraPosition.y = m_Camera.transform.localPosition.y - m_JumpBob.Offset();
            }
            else
            {
                newCameraPosition = m_Camera.transform.localPosition;
                newCameraPosition.y = m_OriginalCameraPosition.y - m_JumpBob.Offset();
            }
            m_Camera.transform.localPosition = newCameraPosition;
        }


        private void GetInput(out float speed)
        {
           

            horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
            vertical = CrossPlatformInputManager.GetAxis("Vertical");

            bool waswalking = m_IsWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
#endif
            // set the desired speed to be walking or running
            speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
            m_Input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
        }


        private void RotateView()
        {
            m_MouseLook.LookRotation (transform, m_Camera.transform);
        }


        private void OnControllerColliderHit(ControllerColliderHit hit)
        {
            Rigidbody body = hit.collider.attachedRigidbody;
            //dont move the rigidbody if the character is on top of it
            if (m_CollisionFlags == CollisionFlags.Below)
            {
                return;
            }

            if (body == null || body.isKinematic)
            {
                return;
            }
            body.AddForceAtPosition(m_CharacterController.velocity*0.1f, hit.point, ForceMode.Impulse);
        }

        public void walkForward()
        {
            vertical = 1f;
        }
        public void walkForwardUp()
        {
            vertical = 0f;
        }
        public void walkBackward()
        {
            vertical = -1f;
        }
    }
}

fps shooter (PlayerScript)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityStandardAssets.CrossPlatformInput;

public class PlayerScript : MonoBehaviour
{
    public Animator Zombieanim;
    public float health = 100f;
    public Slider healthbar;
    public GameObject GameOverScreen;

    public float speed = 5.0f;
    private float rot = 0.0f;
    //public GameObject zombie;
    // Use this for initialization
    void Start () {
      
    }
  
    // Update is called once per frame
    void Update () {
       // CrossPlatformInputManager.GetAxis("Vertical");
    
    }
    void OnTriggerEnter(Collider col)
    {
        if (col.tag == "Enemy"&& !col.GetComponent<Enemy_AI>().isDead) {
            health = health - 0.1f;
            Zombieanim.SetBool ("attack",true);
        }
    }

    void OnTriggerStay(Collider col)
    {
        if (col.tag == "Enemy"&& !col.GetComponent<Enemy_AI>().isDead) {
            health = health - 0.1f;
            healthbar.value = health;

            if (health < 0f )
            {
                print ("you died");
                GameOverScreen.SetActive(true);
            }
        }
    }

    void OnTriggerExit(Collider col)
    {
        if (col.tag == "Enemy") {
            Zombieanim.SetBool ("attack",false);
        }
    }
 
}

FPS SHOOTER (Raycast Shoot Script)

using UnityEngine;
using System.Collections;

public class RaycastShootComplete : MonoBehaviour {

    public int gunDamage = 1;                                          
    public float fireRate = 0.25f;                                   
    public float weaponRange = 50f;                                    
    public float hitForce = 100f;                                     
    public Transform gunEnd;                                           
    public GameObject Particle;

    public GameObject zombie;
    public Animator zombieAnimator;
    public EnemyGenerator enemyGenerator;

    private Camera fpsCam;                                             
    private WaitForSeconds shotDuration = new WaitForSeconds(0.07f);   
    private AudioSource gunAudio;                                      
    private LineRenderer laserLine;                                    
    private float nextFire;                                            

    private Animator anim;
    void Start () 
    {
        anim = GetComponent<Animator> ();
        // Get and store a reference to our LineRenderer component
        laserLine = GetComponent<LineRenderer>();

        // Get and store a reference to our AudioSource component
        gunAudio = GetComponent<AudioSource>();

        // Get and store a reference to our Camera by searching this GameObject and its parents
        fpsCam = GetComponentInParent<Camera>();
    }



    private IEnumerator ShotEffect()
    {
//        Gun.getInstance.PlayAnim ();

    //    this.gameObject.GetComponentInParent<Rigidbody>() .AddForce (new Vector3 (-50f, 0, 0), ForceMode.Impulse);
        GameObject particle = Instantiate (Particle, gunEnd.transform.position, Particle.transform.rotation);
        Destroy (particle, 0.5f);
        // Play the shooting sound effect
        gunAudio.Play ();

        // Turn on our line renderer
        //laserLine.enabled = true;

        //Wait for .07 seconds
        yield return shotDuration;

        // Deactivate our line renderer after waiting
        laserLine.enabled = false;
    }

    public void Fire()
    {
        if ( Time.time > nextFire )
        {//Input.GetButtonDown("Fire1")&& Time.time > nextFire
            // Update the time when our player can fire next
            nextFire = Time.time + fireRate;
            anim.SetTrigger("Shooting");

            // Start our ShotEffect coroutine to turn our laser line on and off
            StartCoroutine(ShotEffect());

            // Create a vector at the center of our camera's viewport
            Vector3 rayOrigin = fpsCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0.0f));

            // Declare a raycast hit to store information about what our raycast has hit
            RaycastHit hit;

            // Set the start position for our visual effect for our laser to the position of gunEnd
            laserLine.SetPosition(0, gunEnd.position);

            // Check if our raycast has hit anything
            if (Physics.Raycast(rayOrigin, fpsCam.transform.forward, out hit, weaponRange))
            {
                // Set the end position for our laser line 
                laserLine.SetPosition(1, hit.point);

                // Check if the object we hit has a rigidbody attached
                if (hit.rigidbody != null)
                {
                    if (hit.collider.tag == "Enemy")
                    {
                        zombieAnimator = hit.transform.gameObject.GetComponent<Animator>();
                        zombieAnimator.SetTrigger("Death");
                        zombie = hit.transform.gameObject;
                        zombie.GetComponent<Enemy_AI>().isDead = true;
                        enemyGenerator.SpawnZombie();
                    }
                    // Add force to the rigidbody we hit, in the direction from which it was hit
                    hit.rigidbody.AddForce(-hit.normal * hitForce);
                }
            }
            else
            {
               // If we did not hit anything, set the end of the line to a position directly in front of the camera at the distance of weaponRange
                laserLine.SetPosition(1, rayOrigin + (fpsCam.transform.forward * weaponRange));
            }
        }
    }
}