سڵاو به ڕێزان لهم با به ته دا با س له ڕێخستنی كۆ مه ڵێك فرمان ئهكه ین بۆ سیلاح
واتهدهركهوتنی شوێنی گولهكهت له سهر نیشانه كهت وهك ئهم وێنهی BulletHole ١- دا نانی
خوارهوه
![[وینه: 27398d8939b3763ed61ee76333b04e61.jpg]](http://www.webchinupload.com/f/2014-09/27398d8939b3763ed61ee76333b04e61.jpg)
ئهوهش ڕێخستینی ئاگره كا تێك فیشهك بته قێنیت ئاگره له لولهی Muzzle Flash -2
سیلا حه كهوه دهرئه جێت وهك ئهم وێنه ی خوارهوه
- 3
(Reload Sound)دانانی دهنگ بۆ ڕێلۆد واتهله دوای ته قاندنی 30 فیشهك دهنگی مهغزهن گۆڕێن بۆ دائهنێین
![[وینه: 6a3797edb0204941975406eecc1f42fa.png]](http://www.webchinupload.com/f/2014-09/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 < 1 && isReloaded == false){
Reload();
}
if(currentAmmo > 0 && shootTimer < 0 && canShoot == true){
Fire();
}
}
if(muzzleTimer > 0 && muzzleFlash){
//muzzleFlash.emit = false;
//lightOne.light.enabled = false;
//lightTwo.light.enabled = false;
//lightThree.light.enabled = false;
}
if(muzzleTimer > 0 && 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(minRandomness, maxRandomness), Random.Range(minRandomness, maxRandomness), Random.Range(minRandomness, maxRandomness));
}
else
{
shootPosition = Vector3(0, 0, 0);
}
if(muzzleTimer < 0 && muzzleFlash){
muzzleFlash.Emit();
}
var hit : RaycastHit;
var direction : Vector3 = transform.TransformDirection(Vector3.forward);
Debug.DrawRay(shootFrom.position + shootPosition, direction * distanceFired, Color.cyan);
if(Physics.Raycast(shootFrom.position + shootPosition, direction, hit, distanceFired)){
var hitRotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
if(hit.transform.tag == "Prop"){
Instantiate(bulletHole, hit.point, hitRotation);
}
if(hit.rigidbody){
if(hit.transform.tag == "Enemy"){
print("BulletHitEnemy");
}
hit.rigidbody.AddForceAtPosition(direction * bulletForce, hit.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;
}
dastt xosh mn amwe bbma admin bas fb kat daxrawa#
ReplyDelete