Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

Search the Community

Showing results for tags 'flashlight'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • GENERAL
    • Introduce yourself
    • Discussions
    • Showcase
    • Need help?
    • Seeking team members?
    • Offtopic
  • RESOURCES
    • Example Projects
    • Scripts
    • Shaders
    • Unity Tutorials
    • FPS Kit Tutorials
    • 3D models
    • Animated 3D Models
    • Graphic design
    • Textures
    • Sounds
    • Other
  • SELL | REQUEST
    • Sell
    • Request
  • Mars' Modular Multiplayer Photon FPS Kit's Topics
  • Mars' Modular Multiplayer Photon FPS Kit's Reviews
  • Mars' Modular Multiplayer Photon FPS Kit's Updates
  • Mars' Modular Multiplayer Photon FPS Kit's Tutorials
  • Busy People's Introductions
  • Photon's Tutorials
  • Photon's Photon General
  • Photon's Showcase

Categories

  • Free Projects
  • Free Assets
  • Game Demos
  • Photon's Files

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


YouTube URL


Facebook URL


Twitter URL


IndieGoGo URL


Kickstarter URL


IndieDB URL


GreenLight URL


Location:


Interests

Found 9 results

  1. This is a very optimized flashlight script. Script contains Main flashlight logic Test example with user input Ready methods and properties to check current state Usage Attach component on gameobject Launch the game Press keyboard button 'F' to simulate activity (check inspector for updated values) Methods and properties bool isActive which returns currrent state of the flashlight Method Toggle for toggling flashlight to opposite state Method Toggle(bool flag) for toggling flashlight to specific state using UnityEngine; using System.Collections; /* * Script written by www.armedunity.com ADG team member 'YoungDeveloper'. * Can be used for commercial projects, but not resold directly or as unity package content. */ /// <summary> /// Handles flashlight action /// </summary> public class Flashlight : MonoBehaviour { [SerializeField]private float _currentBattery = 100f; [SerializeField]private float _maximumBattery = 100f; [SerializeField]private float _batteryDrainSpeedMultiplier = 3f; private bool _isActive = false; public bool isActive { get { return _isActive;} } /// <summary> /// THIS IS A TEST /// </summary> private void Update() { if(Input.GetKeyDown(KeyCode.F)) { Toggle(); } } /// private void OnFlashlightOn() { Debug.Log("Flashlight was turned on."); } private void OnFlashlightOff() { Debug.Log("Flashlight was turned off."); } /// <summary> /// Toggles flashlight to opposite state /// </summary> public void Toggle() { Toggle(!_isActive); } /// <summary> /// Turns flashlight to specific state /// </summary> /// <param name="flag"></param> public void Toggle(bool flag) { //We should enable flashlight if(flag) { if(!_isActive) { if(_currentBattery > 0f) { _isActive = true; StartCoroutine(HandleBatteryDrain()); } else { Debug.Log("Battery can't be turned on. We are out of power."); } } } //We should disable flashlight else { _isActive = false; } } /// <summary> /// Handles Battery drain action, flag check action should be performed before launch. /// </summary> /// <returns></returns> private IEnumerator HandleBatteryDrain() { OnFlashlightOn(); while(_isActive) { _currentBattery -= Time.deltaTime * _batteryDrainSpeedMultiplier; //Baterry was fully drained out if(_currentBattery <= 0f) { Debug.Log("Battery has been drained out!"); _currentBattery = 0f; break; } else { yield return null; } } _isActive = false; OnFlashlightOff(); } }
  2. Hey, I'm using FPS Kit And I want to know how to sync my playr's plash lights That when I will turn my flashlight on, other players will be able to see the light, AND even see the flare that comes from the flashlight. How can I do that? This is something that I have: var light : Light; private var lightOn : boolean = false; function Update () { if(networkView.isMine){ if(Input.GetKeyDown(KeyCode.F)){ if(!lightOn){ networkView.RPC("TurnLightOn", RPCMode.All, true); //Turn on } else{ networkView.RPC("TurnLightOn", RPCMode.All, true); //Turn off } lightOn = !lightOn; } } } @RPC function TurnLightOn (on : boolean) { lightOn = on; if(on){ light.intensity = 1; } else{ light.intensity = 0; } } And I'm getting this error: Assets/Resources/OldScripts/Misc/FlashLight.js(25,9): BCE0004: Ambiguous reference 'light': FlashLight.light, UnityEngine.Component.light.
  3. Hey guys this is my first script so don't hate... It's a basic flashlight script and I've made it for both js and c#. Feed back! JS: C#: +1 rep for more!
  4. var flashLight : Light; function Start(){ flashLight.enabled = false; } function Update () { if(Input.GetKeyDown("f")){ flashLight.enabled = !flashLight.enabled; } } Free to use.
  5. Hallo i am making a horror game and i found a tut about how to make a flashlight use battery and now the funny thing comes. When i am playing the game in the Unity editor i can turn the flashligt off and on but if i build the game the flashligt dont work..Why I have contacted the guy who made this tut but have waited in 2 weeks for a anwser but he dont answer me so i wanna ask you guys and i have put my to scripts down below The guy in the tut called the script TorchController and so do i... TorchController.js : #pragma strict var torchClick : AudioClip; var flashLight : Light; var torchWind : AudioClip; function Start() { flashLight.light.enabled = false; flashLight.light.intensity = 2; } function Update() { if(flashLight.light.enabled == true) { flashLight.light.intensity -= 0.1 * Time.deltaTime / 5; //Debug.Log(flashLight.light.intensity); } if(Input.GetKeyDown("f")) { audio.PlayOneShot(torchClick); if(flashLight.light.enabled == false) { flashLight.light.enabled = true; } else { flashLight.light.enabled = false; } } if(flashLight.light.enabled == true && Input.GetKeyDown("q")) { flashLight.light.intensity += 0.05; audio.PlayOneShot(torchWind); } } BatteryPickup_Ray.js : private var torchScript : TorchController; private var guiShow : boolean = false; var battery : GameObject; var rayLength = 10; function Start() { torchScript = GameObject.Find("FlashLight").GetComponent(TorchController); } function OnGUI() { if(guiShow == true) { GUI.Box(Rect(Screen.width / 2, Screen.height / 2, 100, 25 ), "Pick up batteries!"); } } function Update() { //Debug.Log(guiShow); var hit : RaycastHit; var fwd = transform.TransformDirection (Vector3.forward); if (Physics.Raycast (transform.position, fwd, hit, rayLength)) { if(hit.collider.gameObject.tag == "Battery") { guiShow = true; if(Input.GetKeyDown("e")) { torchScript.flashLight.light.intensity += 0.5; Destroy(battery); guiShow = false; } } } else { guiShow = false; } }
  6. Hi guys, here is my flashlight script with batteries /* * NDev Studios * Flashlight Script * Version 1.0 */ using UnityEngine; using System.Collections; public class FlashLightScript : MonoBehaviour { public Light flashlight; public GUISkin myskin; public AudioSource sounderplayer; public AudioClip OpenSound; public static float battaryP = 100.0f; public static bool owned = false; private bool isopen = false; private int countmessage = 0; //Bar Visuals public Texture2D b100,b90,b80,b70,b60,b50,b40,b30,b20,b10,b0; //Need 11 textures with a progress bar that has the following values : 100% , 90%, 80%, 70% , 60% , 50% , 40% , 30% , 20% , 10% , 0% void Update() { if (Time.timeScale != 0.0f) { if (owned == true) { if (countmessage > 0) { countmessage --; } if (Input.GetKeyDown (KeyCode.F)) { //Change Key Here sounderplayer.clip = OpenSound; sounderplayer.loop = false; sounderplayer.Play (); if (battaryP > 0.0f) { if (isopen == false){ isopen = true; }else{ isopen = false; } } else{ countmessage = 75; } EnableDisableFlashLight (); } if (isopen == true) { battaryP -= 0.05f; } if (battaryP <= 0.0f && isopen == true) { isopen = false; EnableDisableFlashLight (); } }else isopen = false; EnableDisableFlashLight(); } } void OnGUI() { if (countmessage > 0) { GUI.skin = myskin; GUI.Label (new Rect(Screen.width / 2 - 100, Screen.height / 2 + 0, 300, 45),"Low Battary!"); } if (owned == true && Time.timeScale != 0.0f) { if (battaryP > 90.0f) { GUI.DrawTexture (new Rect(Screen.width / 2 + 300, 0,335,37),b100); } else if (battaryP <= 90.0f && battaryP > 80.0f) { GUI.DrawTexture (new Rect(Screen.width / 2 + 300, 0,335,37),b90); } else if (battaryP <= 80.0f && battaryP > 70.0f) { GUI.DrawTexture (new Rect(Screen.width / 2 + 300, 0,335,37),b80); } else if (battaryP <= 70.0f && battaryP > 60.0f) { GUI.DrawTexture (new Rect(Screen.width / 2 + 300, 0,335,37),b70); } else if (battaryP <= 60.0f && battaryP > 50.0f) { GUI.DrawTexture (new Rect(Screen.width / 2 + 300, 0,335,37),b60); } else if (battaryP <= 50.0f && battaryP > 40.0f) { GUI.DrawTexture (new Rect(Screen.width / 2 + 300, 0,335,37),b50); } else if (battaryP <= 40.0f && battaryP > 30.0f) { GUI.DrawTexture (new Rect(Screen.width / 2 + 300, 0,335,37),b40); } else if (battaryP <= 30.0f && battaryP > 20.0f) { GUI.DrawTexture (new Rect(Screen.width / 2 + 300, 0,335,37),b30); } else if (battaryP <= 20.0f && battaryP > 10.0f) { GUI.DrawTexture (new Rect(Screen.width / 2 + 300, 0,335,37),b20); } else if (battaryP <= 10.0f && battaryP > 1.0f) { GUI.DrawTexture (new Rect(Screen.width / 2 + 300, 0,335,37),b10); } else if (battaryP <= 1.0f) { GUI.DrawTexture (new Rect(Screen.width / 2 + 300, 0,335,37),b0); } } } void EnableDisableFlashLight() { if (isopen == true) { flashlight.enabled = true; } else { flashlight.enabled = false; } } } to load batteries just add a script with FlashLightScript.battaryP = 100.0f; //Or any value from 0.0f to 100.0f
  7. Hey guys Plz no hate I am noob to coding just startet becruse i want to learn how to Javascript and C#. Now i just made my frist working Script without any help !! So i will give this out so you guys just can use this Here this is : P.S : If you know how to learn coding easy or fast so plz hit me op Update !!!! I just made this without help i am so fucking glad becruse i made this !!! FlahsLight Code : var LightOnAndOff = false; var ShowText = false; var GiveDammge = 50; static var Nice = 0; function Start () { } function Update () { if(Input.GetKeyDown("f")) { if (LightOnAndOff == false) { LightOnAndOff = true; light.enabled = true; }else{ LightOnAndOff = false; light.enabled = false; } } if(Input.GetKeyDown("b")) { if (ShowText == false) { ShowText = true; }else{ ShowText = false; } } if(Input.GetKeyDown("k")) { ZombieDamgeAndHealth.ZombieHealth -= GiveDammge; } } function OnTriggerEnter(other : Collider) { if(other.gameObject.tag == "Zombie") { Health -= ZombieDamgeAndHealth.ZombieDmag; } } function OnGUI () { if(ShowText == true) { //Box(Rect(50, 50, 50, 50), "See Here!!"); GUILayout.Label("Health :" + Health); GUILayout.Label("Zombie Health :" + ZombieDamgeAndHealth.ZombieHealth); GUILayout.Label("LightOn :" + LightOnAndOff); GUILayout.Label("Nice :" + Nice); } } And this is the ZombieDamgeAndHealth Script ! #pragma strict static var ZombieDmag = 20; static var ZombieHealth = 100; var MoneyToGive = 20; function Start () { } function Update () { if(ZombieHealth <= 1) { Die (); } } function Die () { FlahsLight.Nice += MoneyToGive; Destroy(this.gameObject); } Thanks for looking on my post How to use the scripts : 1). Put the "FlahsLight" script on your Player 2). And then put the "ZombieDamgeAndHealth" script on the cube/Zombie and tag the zombie to "Zombie" 3). You are done !!
  8. Hello everyone I'm created a FlashLight Script. It's working but the light automatically on... Please Help var lightOfEpicness : Transform; var clickAudio : AudioClip; function Start () { lightOfEpicness.enabled = false; } function Update () { if(Input.GetKeyUp(KeyCode.F)){ audio.clip = clickAudio; audio.Play(); if(lightOfEpicness.active == true){ lightOfEpicness.active = false; } else { lightOfEpicness.active = true; } } }
  9. Put audio Source to your Spotlight Here Script Have 2 audioclip On And off Js var flashlightOn : boolean = false; var soundOn : AudioClip; var soundOff : AudioClip; var onIntensity = 5.0; var offIntensity = 0.0; function Update () { //Checks if the F key is down and whether the boolean is on or off. if(Input.GetKeyDown(KeyCode.F) && flashlightOn == false){ AudioSource.PlayClipAtPoint(soundOn, light.transform.position); flashlightOn = true; //If the f key is down and the boolean is false, it sets the boolean to true. light.intensity = onIntensity; } else { if(Input.GetKeyDown(KeyCode.F) && flashlightOn == true) { AudioSource.PlayClipAtPoint(soundOff, light.transform.position); flashlightOn = false;//If the f key is down and the boolean is true, it sets the boolean to false. light.intensity = offIntensity; } } } Bye.
×
×
  • Create New...