Thursday, 21 December 2017

Unity 3d First Person Shooter (FPS) - Hindi/Urdu [02]





Unity 3d First Person Shooter FPS - Hindi Urdu for beginners.
https://www.unity3d.com
https://www.udemy.com
Do you want to know how to make an FPS in Unity? Making a shooter in Unity is easy for beginners. Using Unity.
everything will be as simple as possible.
First Person Shooter elements: WSAD-Movement Looking around with the Mouse; A decent looking weapon further we will create enemy AI and weapon switching if possible stay tuned .

like and subscribe if you liked the video and share it.

Script download
-- http://urdutechtutorials.blogspot.com/2017/12/unity3d-fps- shooter-script-c.html

Unity3d FPS Shooter Script c#

  WATCH COMPLETE VIDEO TUTORIAL ON YOUTUBE CHANNEL HERE

using UnityEngine;
using System.Collections;

public class RaycastShootComplete : MonoBehaviour {

    public int gunDamage = 1;                                           // Set the number of hitpoints that this gun will take away from shot objects with a health script
    public float fireRate = 0.25f;                                      // Number in seconds which controls how often the player can fire
    public float weaponRange = 50f;                                     // Distance in Unity units over which the player can fire
    public float hitForce = 100f;                                       // Amount of force which will be added to objects with a rigidbody shot by the player
    public Transform gunEnd;                                            // Holds a reference to the gun end object, marking the muzzle location of the gun
    public GameObject Particle;

    private Camera fpsCam;                                              // Holds a reference to the first person camera
    private WaitForSeconds shotDuration = new WaitForSeconds(0.07f);    // WaitForSeconds object used by our ShotEffect coroutine, determines time laser line will remain visible
    private AudioSource gunAudio;                                       // Reference to the audio source which will play our shooting sound effect
    private LineRenderer laserLine;                                     // Reference to the LineRenderer component which will display our laserline
    private float nextFire;                                             // Float to store the time the player will be allowed to fire again, after firing


    void Start () 
    {
        // 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>();
    }


    void Update () 
    {
        //Input.GetKey("Fire1")
        // Check if the player has pressed the fire button and if enough time has elapsed since they last fired
        if ( Input.GetButtonDown("Fire1")&& Time.time > nextFire) 
        {//Input.GetButtonDown("Fire1")&& Time.time > nextFire
            // Update the time when our player can fire next
            nextFire = Time.time + fireRate;

            // 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)
                {
                    // 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));
            }
        }
    }


    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;
    }
}

Tuesday, 19 December 2017

Unity3d First Person Shooter Tutorial ( Hindi / Urdu) [01]



Complete tutorial on how to create or make a fps (first person shooter) game in unity in hindi urdu.

In this Tutorial we will learn how to make a First Person Shooter (FPS) game in Unity. As usual, everything will be as simple as possible. We will focus on the following First Person Shooter elements: W SAD-Movement & Jumping; Looking around with the Mouse; A decent looking weapon further we will create enemy AI and weapon switching f possible stay tuned .

https://www.unity3d.com
https:www.turbosquid.com