دانانی كۆ مه‌ڵێك فرمان بۆ سیلاح (BulletHole , Muzzle Flash, Reload Sound) له‌ unity3d

سڵاو به‌ ڕێزان له‌م با به‌ ته‌ دا با س له‌ ڕێخستنی كۆ مه‌ ڵێك فرمان ئه‌كه‌ ین بۆ سیلاح 
 واته‌ده‌ركه‌وتنی شوێنی گوله‌كه‌ت له‌ سه‌ر نیشانه‌ كه‌ت وه‌ك ئه‌م  وێنه‌ی BulletHole   ١دا نانی 
خواره‌وه‌
[وینه‌: 27398d8939b3763ed61ee76333b04e61.jpg]

ئه‌وه‌ش ڕێخستینی ئاگره‌ كا تێك فیشه‌ك بته‌ قێنیت ئاگره‌ له‌ لوله‌ی Muzzle Flash -2
سیلا حه‌ كه‌وه‌ ده‌رئه‌ جێت وه‌ك ئه‌م وێنه‌ ی خواره‌وه‌ 

[وینه‌: 2dab12bb708a2bf7b14b67e20d71ff73.jpg]
- 3
 (Reload Sound)دانانی ده‌نگ بۆ ڕێلۆد واته‌له‌ دوای ته‌ قاندنی 30 فیشه‌ك ده‌نگی مه‌غزه‌ن گۆڕێن بۆ دائه‌نێین   



[وینه‌: 6a3797edb0204941975406eecc1f42fa.png]

با زۆر سه‌ر تان نه‌ یه‌ شێنم زۆری تریشه‌ ئه‌مه‌ ڤیدۆ كه‌م 

پێویستیه‌كان Download
Shoot Script 

کۆدی PHP::



#pragma strict

var weaponModel GameObject;
var shootFrom Transform;
var playerModel Transform;
var bulletHole GameObject;

var muzzleFlash ParticleEmitter;

var lightOne GameObject;
var lightTwo GameObject;
var lightThree GameObject;

var maxRandomness float 1.0f;
var minRandomness float 0.0f;

var shootPosition Vector3;

var shootTimer float 0.0f;
var shootCooler float 0.0f;

var muzzleTimer float 0.0f;
var muzzleCooler float 0.1f;

var bulletForce int 0;
var bulletDamage int 0;
var distanceFired int 0;

var timeToReload float 0.0f;

var currentAmmo int 0;
var currentClip int 6;
var ammoPerClip int 30;

var isReloaded boolean false;
var canShoot boolean true;

var reloadSound AudioClip;
var shootSound AudioClip;

function Start () {
    currentAmmo ammoPerClip;
    Screen.showCursor false;
    muzzleFlash.emit false;
}

function Update () {
    if(Input.GetMouseButton(0)){
        if(currentAmmo && isReloaded == false){
            Reload();
        }
        if(currentAmmo && shootTimer && canShoot == true){
            Fire();
        }
    }
    if(muzzleTimer && muzzleFlash){
        //muzzleFlash.emit = false;
        //lightOne.light.enabled = false;
        //lightTwo.light.enabled = false;
        //lightThree.light.enabled = false;
    }
    
    if(muzzleTimer && Input.GetMouseButtonDown){
        lightOne.light.enabled = !lightOne.light.enabled;
        lightTwo.light.enabled = !lightTwo.light.enabled;
        lightThree.light.enabled = !lightThree.light.enabled;
        muzzleFlash.emit false;
    }
    shootTimer -= Time.deltaTime;
    muzzleTimer -= Time.deltaTime;
}

function Fire () {
    if(currentAmmo 0){
        if(!Input.GetMouseButtonDown(1)){
            shootPosition Vector3(Random.Range(minRandomnessmaxRandomness), Random.Range(minRandomnessmaxRandomness), Random.Range(minRandomnessmaxRandomness));
        }
        else
        {
            shootPosition Vector3(000);
        }
        
        if(muzzleTimer && muzzleFlash){
            muzzleFlash.Emit();
        }

        var hit RaycastHit;
        var direction Vector3 transform.TransformDirection(Vector3.forward);
        
        Debug.DrawRay(shootFrom.position shootPositiondirection distanceFiredColor.cyan);
        
        if(Physics.Raycast(shootFrom.position shootPositiondirectionhitdistanceFired)){
            var hitRotation Quaternion.FromToRotation(Vector3.uphit.normal);
            if(hit.transform.tag == "Prop"){
                Instantiate(bulletHolehit.pointhitRotation);
            }
            if(hit.rigidbody){
                if(hit.transform.tag == "Enemy"){
                    print("BulletHitEnemy");
                }
                
                hit.rigidbody.AddForceAtPosition(direction bulletForcehit.point);
            }
        }
        
        currentAmmo --;
        
        shootTimer shootCooler;
        muzzleTimer muzzleCooler;
        
        if(shootSound){
            audio.PlayOneShot(shootSound);
        }
    }
}

function Reload () {
    isReloaded true;
    if(reloadSound){
        audio.PlayOneShot(reloadSound);
    }
    yield WaitForSeconds(timeToReload);
    if(currentClip 0){
        currentAmmo ammoPerClip;
        currentClip -= 1;
    }
    isReloaded false;



  Karwan.H :وەرگیراوە لە بەرێز 


ڵەگەڵ رێزم بەرێوبەری مەڵپەڕ : کاروان رمضان


1 comment: Leave Your Comments

زیاتر

Whats Hot