UNİTY 3D SES EFEKTLERİ VE KODLARI
Bu Eğitimde Attığınız Merminin Çarpma Hızına Ve Şiddetine Göre Rastgele Çarpma
Sesleri Çıkartmayı Öğreneceksiniz...
MERMİ SCRİPT:
C#
using UnityEngine;
using System.Collections;
public class ThrowObject : MonoBehaviour {
public GameObject projectile;
public AudioClip shootSound;
private float throwSpeed = 2000f;
private AudioSource source;
private float volLowRange = .5f;
private float volHighRange = 1.0f;
void Awake () {
source = GetComponent<AudioSource>();
}
void Update () {
if (Input.GetButtonDown("Fire1"))
{
float vol = Random.Range (volLowRange, volHighRange);
source.PlayOneShot(shootSound,vol);
GameObject throwThis = Instantiate (projectile, transform.position, transform.rotation) as GameObject;
throwThis.rigidbody.AddRelativeForce (new Vector3(0,0,throwSpeed));
}
}
}
ÇARPMA SESLERİ SCRİPT:
C#
using UnityEngine;
using System.Collections;
public class CrashSound : MonoBehaviour {
public AudioClip crashSoft;
public AudioClip crashHard;
private AudioSource source;
private float lowPitchRange = .75F;
private float highPitchRange = 1.5F;
private float velToVol = .2F;
private float velocityClipSplit = 10F;
void Awake () {
source = GetComponent<AudioSource>();
}
void OnCollisionEnter (Collision coll)
{
source.pitch = Random.Range (lowPitchRange,highPitchRange);
float hitVol = coll.relativeVelocity.magnitude * velToVol;
if (coll.relativeVelocity.magnitude < velocityClipSplit)
source.PlayOneShot(crashSoft,hitVol);
else
source.PlayOneShot(crashHard,hitVol);
}
}
İlgili Yazı
UNİTY 3D PARENT
UNİTY 3D PARENT - CHİLD
Parent Child Bir objenin altındaki objelerdir bu genelde pek işimi
UNİTY 3D PARTİCLE
Oyunlarda Yapacağınız En Önemli Olaylardan birisi ise Particle Systemdir.
Particle System Oyu
UNİTY 3D SAHNE OLUŞTURMA
Sahneler Oyunların Kısım Kısım Ayırdığımız Alanlardır. Örnek Verecek Olursak Ana Menüy
Unity 3D YAPAY ZEKA ATEŞ ETME SİSTEMİ
Bir Önceki Derste Yaptığımız Yapay Zekanın Üzerinden Devam Ediyoruz. Bir Önceki Derse
BURADAN
UNİTY 3D LİGHTMAPPİNG
UNİTY 3D LİGHTMAPPİNG
Bir Oyun Yaptığınızda Bunu optimize etmemiz gere
UNİTY 3D TERRAİN
Unity 3d Programında belirli objeleri oluşturmanıza olanak sunar küp,küre,silindir