Konuyu Oyla:
  • Toplam: 0 Oy - Ortalama: 0
  • 1
  • 2
  • 3
  • 4
  • 5
El Feneri Scripti Unity
#1

  1. PHP Source Code
    1. [/url]using UnityEngine;using System.Collections;



    2. [RequireComponent(typeof(Light), typeof(AudioSource))]

    3. public class Flashlight : MonoBehaviour {

    4. public AudioClip clickSound;

    5. public float batteryLifeInSec = 300f;

    6. public float batteryPercentage = 100;



    7. private bool on;

    8. private float timer;



    9. void Update() {

    10. Light lite = GetComponent<Light>();

    11. timer += Time.deltaTime;



    12. if(Input.GetKeyDown(KeyCode.F) && timer >= 0.3f && batteryPercentage > 0) {

    13. on = !on;

    14. audio.PlayOneShot(clickSound);

    15. timer = 0;

    16. }



    17. if(on) {

    18. lite.enabled = true;

    19. batteryPercentage -= Time.deltaTime * (100 / batteryLifeInSec);

    20. }

    21. else {

    22. lite.enabled = false;

    23. }



    24. batteryPercentage = Mathf.Clamp(batteryPercentage, 0, 100);



    25. if(batteryPercentage == 0) {

    26. lite.intensity = Mathf.Lerp(lite.intensity, 0, Time.deltaTime * 2);

    27. }



    28. if(batteryPercentage > 0 && batteryPercentage < 25) {

    29. lite.intensity = Mathf.Lerp(lite.intensity, 0.5f, Time.deltaTime);

    30. }



    31. if(batteryPercentage > 25 && batteryPercentage < 75) {

    32. lite.intensity = Mathf.Lerp(lite.intensity, 0.8f, Time.deltaTime);

    33. }



    34. if(batteryPercentage > 75 && batteryPercentage <= 100) {

    35. lite.intensity = Mathf.Lerp(lite.intensity, 1, Time.deltaTime);

    36. }

    37. [url=http://oyun-programlama.com/Thread/38826-el-feneri-scripti-unity/#codeLine_47_e3e531] } }

Dalgalanan%20Bayrak%20Resmi.gif
vEJJ86.gif
Ara
Cevapla }}}}
#2
Teşekkürler
dbZ7QV.png
OZRv7A.gif
Ara
Cevapla }}}}


Hızlı Menü:


Şu anda bu konuyu okuyanlar: 1 Ziyaretçi

Online Shopping App
Online Shopping - E-Commerce Platform
Online Shopping - E-Commerce Platform
Feinunze Schmuck Jewelery Online Shopping