NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

public class temaslayokol : MonoBehaviour {
public GameObject patlama;
public GameObject playerpatlama;
GameObject Oyunkontrol;
oyunkontrol baglanti;
// Use this for initialization
void Start()
{
Oyunkontrol = GameObject.FindGameObjectWithTag("oyunkontrol");//unity'de oynkontrole tag verildi unity'e git tag'i oyun kontrol olan objeyi bul
baglanti = Oyunkontrol.GetComponent<oyunkontrol>(); //
}
void OnTriggerEnter(Collider col) // temas ettiği anda metot çalışır
{
if (col.tag != "sinir")//asteroid nesnesine temas eden diğer nesnenin tag'i sinir değil ise
{
Destroy(col.gameObject);//temas eden nesneyi yok et
Destroy(gameObject);//astreoid'i yok et
Instantiate(patlama, transform.position, transform.rotation);//temasın olduğuposition ,rotationpatlama efekti(explotion astreoid) oluştur
baglanti.ScoreArttir(100);//skor'u 100 artır
}
if (col.tag == "Player")//astoride temas eden nesnenin tag'i player ise
{
Instantiate(playerpatlama, col.transform.position, col.transform.rotation);

//temasın olduğu yerde player patlama efektini(explotion player) oluştur
baglanti.oyunbitir();
}
}
}
public class sinirlar : MonoBehaviour {

// Use this for initialization
private void OnTriggerExit(Collider col)//temastan çıkıldığında bu metodu çalıştır.
{
Destroy(col.gameObject);//sınıra temas eden tüm nesneleri sil
//kursun sahneden çıktıktan sonra hierarchy silinmesi
}

}
public class rotasyon : MonoBehaviour {//angularvelocity =göktaşının kendi etrafında dönmesi
Rigidbody fizik;
public int hiz;
// Use this for initialization
void Start () {
fizik = GetComponent<Rigidbody>(); //
fizik.angularVelocity = Random.insideUnitSphere*hiz;//rastgele küresel bir hareketle dön göktaşı////sormaz
}
// Update is called once per frame
void Update () {

}
}

public class playerkontrol : MonoBehaviour {
AudioSource ses;
Rigidbody fizik;
float yatay;
float dikey;
Vector3 vec;
public int hiz;
public float minX;
public float maxX;
public float minZ;
public float maxZ;
public float egim;
public float ateszamani = 0;
public float zaman;
public GameObject kursun;
public Transform kursuncikisyeri;
// Use this for initialization
void Start () {
fizik = GetComponent<Rigidbody>(); // nesneye ait rigidbody componentini bir değişken olarak atama
ses = GetComponent<AudioSource>();
}
// Update is called once per frame
private void Update()
{
if (Input.GetButton("Fire1") && Time.time>ateszamani)//eğer farenin soltuşuna basıldıysa ve time.time yani otomatik sayac
//ateşzamanından büyük isie
{
ateszamani = Time.time + 1;//ateşzamanına time.time'ın üzerine 1 ekleyerek artır.
Instantiate(kursun, kursuncikisyeri.position,Quaternion.identity); //kurşunun çıkış yeriyle belirlenen pozisyonda yıldırım frefab'ını
//yani kurşun nesnesini oluştur

}
}
void FixedUpdate () {
yatay = Input.GetAxis("Horizontal");
dikey = Input.GetAxis("Vertical");
vec = new Vector3(yatay, 0, dikey);
fizik.velocity = vec*hiz;

fizik.position = new Vector3
(Mathf.Clamp(fizik.position.x, minX,maxX), 0.0f, Mathf.Clamp(fizik.position.z, minZ, maxZ));//
fizik.rotation = Quaternion.Euler(0, 0, fizik.velocity.x * -egim);
}

}
public class patlamasil : MonoBehaviour {

// Use this for initialization
void Start () {
Destroy(gameObject, 3);
public class fxkontrol : MonoBehaviour {
Rigidbody fizik;
public int hiz;
// Use this for initialization
void Start () {
fizik = GetComponent<Rigidbody>();
fizik.velocity = transform.forward*hiz;// kurşunu ileri doğru hareket ettirmek için

}

// Update is called once per frame
void Update () {

}
public class asteroidhareket : MonoBehaviour {
Rigidbody fizik;
public int hiz;
public int a;
// Use this for initialization
void Start()
{
fizik = GetComponent<Rigidbody>();
fizik.velocity = transform.forward * hiz;//göktaşına hareket verme
}
// Update is called once per frame
void Update () {

}
}

public class oyunkontrol : MonoBehaviour
{
public GameObject Asteroid;
public Vector3 randomPos;
int score;
public Text text;
bool oyunbitiskontrol = false;
bool yenidenbaslatkontrol = false;
public Text oyunbitis;
public Text yenidenbaslama;
// Use this for initialization
void Start()
{
score = 0;
text.text = "score=" + score;
StartCoroutine(olustur());
}

// Update is called once per frame
void Update()
{
if(Input.GetKeyDown(KeyCode.R)&& yenidenbaslatkontrol)//klavyenin r tuşuna basıldıysa ve ........... oyunu yeniden başlat
{
SceneManager.LoadScene("oyun2");//oyunu yeniden başlat
// Debug.Log("Yeniden Başladıııı");
}
}
IEnumerator olustur()//önemli
{
while (true)
{
for (int i = 0; i < 10; i++)
{
Vector3 vec = new Vector3(Random.Range(-randomPos.x, randomPos.x), 0, randomPos.z);//vektör 3 ün x parametresi Random pos x değerine göre min ve max değerler alsın
//yani -x ile +x arasında değerler alsın.//vektör 3 ün yparametresi yalnızca unity'de girilecek olan random pos değerini alsın
Instantiate(Asteroid, vec, Quaternion.identity);
yield return new WaitForSeconds(1);
}
if (oyunbitiskontrol)
{
yenidenbaslama.text = "Yeniden başlatmak için R'ye basınız";
yenidenbaslatkontrol = true;
break;
}
yield return new WaitForSeconds(3);
}
} //en önemli script oyunkontrol
public void ScoreArttir(int gelenscore)
{
score += gelenscore;
text.text = "score=" + score;
}
public void oyunbitir()
{
oyunbitis.text = " OYUN BİTTTTİİİİ";
// Debug.Log("OYUN BİTTİİİİ");
oyunbitiskontrol = true;

}
}
UZAY OYUNU
bir nesneye hareket vermek için rigidbody

skylebox'ı kapat
1- main camera seçiliyken kamera componentindeki clear flags özelliği solid color olarak seçilir.background rengi olarakta siyah seçtik.
2- Oyuna ait hazır modelleri,prefabları,materyalleri,sesleri assets store'a space shooter yazarak import ettik.
3- game ekranını dikey hale getirmek için free aspect kısmından genişlik ve yükseklik ayarları 600 - 900 olarak seçildi.
4- models klasöründen vehicle player ship seçilerek sahnedeki 0,0,0 noktasına sürüklenir.
5- uzay aracının adı player olarak değiştirildi.
6- player nesnesine rigidbody component'i eklenir.Use Gravity özelliği kapatılır.
7- prefabs klasöründen vpx-engines-enginesplayer uzay aracının arka kuyruğuna doğru sürüklenerek bırakılır.
8- main camera seçilir. Position=0,10,4 / rotation=90,0,0 olarak değiştirilir
9- Player nesnesine ait yeni bir c# script oluşturulur.script'in adı playerkontrol olarak değiştirilir. Ve bu script player nesnesine bbir component olarak atanır.
KURŞUN OLUŞTURMA
1- 0,0,0 noktasına boş bir object eklenir.Adı yılıdırım olarak değiştirilir.
2- yıldırıma alt nesne olarak quad eklenir.quat = rotation=90,0,0, quatın adın fx olarakdeğiştirilir.
3- Assets 'de yer alan Textures fxlazerorangedps seçilerek quad'ın üstüne sürüklenir.
4- fx seçiliyken mesh collider component'i kaldırılır.
5- fx lazer orange dff component'i açılır.
6- Assets'te yeni bir materyal oluşturulur ve adı fxmat olarak değiştirilir.
7- Bu materyalin schedor'ı (ekran kartına ait kodlar) partcals Editiv olarak değiştirilir ve select seçeneğinden fx lazer dff seçilir
hazır olan materyal kurşunun üzerine sürüklenerek bırakılır(önemli)
8- yıldırım nesnesine Rigidbody component'i eklenir.Use Gravity kapatılır.
9- yıldırım nesnesine capsule collider component'i eklenir .Direction özelliği z axis olarak değiştirilir.
10- kodlar klasörüne yeni bir c# script oluşturulur.adı fx kontrol olarak değiştirilir. ve yıldırım nesnesine component olara verilir.Assets'in içine bizim frefablar adında yenni bir klasör oluşturulur.yıldırım nesnesi bu klasörün iiçine sürüklenerek frefab haline getirilir.ve hiyerarşidedn silinir.
ATEŞ ETMEK
1- boş bir objr eklenir. adı kursununcikisyeri olarak değiştirilir. bu nesne player'in içine atılır ve player'ın alt nesnesi haline getirilir ve position=0,0,1 olarak değiştirilir(uçuğın önüne ayarlamak için) sonra playerkontrol script'ine gelerek gerekli kodlar yazılır.
SINIR OLUŞTURMA
1- sahneye bir küp eklenir adı sınır olarak değiştirilir
2- is trigger özelliği true yapılır
3- position=0,0,5---scale=15,1,20 olarak değiştirilir
5- Mesh renderer component'i kaldırılır.(sadece çizgiler gözüksün diye)
6- yeni bir c# script oluşturulur.
7- adı sınırlar olarak değiştirilir
8-sınır objesine component olarak atanır ve açılır.
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.