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 'trigger'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


    • Introduce yourself
    • Discussions
    • Showcase
    • Need help?
    • Seeking team members?
    • Offtopic
    • Example Projects
    • Scripts
    • Shaders
    • Unity Tutorials
    • FPS Kit Tutorials
    • 3D models
    • Animated 3D Models
    • Graphic design
    • Textures
    • Sounds
    • Other
    • 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


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

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL





YouTube URL

Facebook URL

Twitter URL

IndieGoGo URL

Kickstarter URL


GreenLight URL



Found 11 results

  1. HI! Here a script i wrote for my game. Hope that will help someone! //TriggerEvent.cs by isod89 using UnityEngine; using System.Collections; using UnityEngine.Events; public class TriggerEvent : MonoBehaviour { public enum TriggerType { Infinite, SingleUse, Timed } public TriggerType TriggerTypes = TriggerType.Infinite; private bool triggered = false; private bool SingleTrigger = false; private bool Singletriggered = false; private bool TimerTrigger = false; private bool timerstart = false; private bool timerfinish = true; public float timerDuration = 15; private float timeleft = 1; public Color triggerboxColour; public UnityEvent onTrigger; public UnityEvent onTriggerExit; void Start() { //trigger type check if (TriggerTypes == TriggerType.SingleUse) { SingleTrigger = true; } //trigger type check if (TriggerTypes == TriggerType.Timed) { TimerTrigger = true; } timeleft = timerDuration; } void OnDrawGizmos() { //draw gizmos in editor Gizmos.color = triggerboxColour; Gizmos.DrawCube(new Vector3(GetComponent<Collider>().bounds.center.x, GetComponent<Collider>().bounds.center.y, GetComponent<Collider>().bounds.center.z), new Vector3(GetComponent<Collider>().bounds.size.x, GetComponent<Collider>().bounds.size.y, GetComponent<Collider>().bounds.size.z)); } void Update() { //Single Trigger Timer if (timerstart == true) { timeleft -= Time.deltaTime; } //Single Trigger Timer if (timeleft < 0) { timerstart = false; timeleft = timerDuration; timerfinish = true; } } void OnTriggerEnter ( Collider col ){ //Infinite Trigger if(col.gameObject.tag == "Player" & Singletriggered == false & SingleTrigger == false & TimerTrigger == false) { triggered = true; onTrigger.Invoke(); Debug.Log(gameObject.name + " has been INFINITE triggered!"); } //Single Trigger if (col.gameObject.tag == "Player" & Singletriggered == false & SingleTrigger == true & TimerTrigger == false) { Singletriggered = true; triggered = true; onTrigger.Invoke(); Debug.Log(gameObject.name + " has been SINGLE triggered!"); } //Timer Trigger if (col.gameObject.tag == "Player" & Singletriggered == false & SingleTrigger == false & TimerTrigger == true & timerfinish == true & timerstart == false) { timerstart = true; triggered = true; onTrigger.Invoke(); Debug.Log(gameObject.name + " has been TIMER triggered!"); } } void OnTriggerExit(Collider col) { //Timer Trigger if (col.gameObject.tag == "Player" & timerstart == true & triggered == true) { onTriggerExit.Invoke(); triggered = false; } //Infinite Trigger if (col.gameObject.tag == "Player" & SingleTrigger == false & TimerTrigger == false & triggered == true) { triggered = false; onTriggerExit.Invoke(); } //Single Trigger if (col.gameObject.tag == "Player" & SingleTrigger == true & triggered == true) { onTriggerExit.Invoke(); Destroy(transform.gameObject); } } }
  2. This script will let you switch scenes by pressing on a Collider. Download How to use. ------------ 1. Make a GameObject in your scene. 2. Create a Collider on that GameObject. 3. Make sure that the GameObject is on the Camera. 4. Copy the Menu Script on the GameObject. 5. Save the Scene and create a new Scene. 6. Save both Scenes give it a name. 7. Add the both Scenes to the Build. 8. Go to the first scene where you created the GameObject and select the GameObject. 9. When selected go to the Inpector and you can write the other scene name you want to load. 10. THAT'S IT!! ------------
  3. Hello all, I'm a unity newbie I am trying to restrict movement inside a trigger once the player touches the edge of the trigger to stop moving and I want to restrict the axis they player can move on while in the trigger I have a trigger set just in front of wall of object currently I have the camera changing only when trigger is active and the right mouse button is clicked the trigger is the same dimensions as the wall object
  4. Hi guys! I created this very simple script. When the player go in a Trigger zone audio.Play and when the player exit audio.Stop. Script (Js) function OnTriggerEnter(){ audio.Play(); } function OnTriggerExit(){ audio.Stop(); }
  5. How do i enable, or show some object on trigger or if in radius. just for better performance!
  6. Hi everyone, I have a scene where the player can move and rotate a cube by touch. So the player can touch anywhere one the screen and move the cube but I wanna make a collider where the cube can go through. What is the best way to do that?
  7. Hey guys! Im trying to make a radio like object in my game. I want it so when I walk up to my "Radio" Object I can press "E" It will play the song. And when I press "E" Again it stops playing the song. I looked it up on Google but couldn't find much on how to do it. Im not the best Coder. So I don't know what to do. I would appreciate it if you guys could help me. Or send me a link to a video or a web page on how to do it. Thanks -Stuart
  8. Hey guys, So I have this door script (It's actually not mine I got it from desert fortress pack) and I'm using it with the FPS kit By OMA. I can't figure out how to add the "press e to use" gui that is on the weapon pickup and stuff. I want to figure out a way to add that gui to the door. Thanks! using UnityEngine; using System.Collections; //Instruction: //Make an empty game object and call it "Door" //Rename your 3D door model to "Body" //Parent a "Body" object to "Door" //Make sure thet a "Door" object is in left down corner of "Body" object. The place where a Door Hinge need be //Add a box collider to "Door" object and make it much bigger then the "Body" model, mark it trigger //Assign this script to a "Door" game object that have box collider with trigger enabled //Press "e" (Default) to open and close the door //Make sure the main character is tagged "player" public class open_door : MonoBehaviour { public float smooth = (float)2.0; public float DoorOpenAngle = (float)110.0; public float DoorCloseAngle = (float)0.0; public bool open = false; public bool enter = false; public string defined_key = "e"; // Update is called once per frame void Update () { if(open == true) { var target = Quaternion.Euler (transform.localRotation.x, DoorOpenAngle, transform.localRotation.z); // Dampen towards the target rotation transform.localRotation = Quaternion.Slerp(transform.localRotation, target, Time.deltaTime * smooth); } if(open == false) { var target1 = Quaternion.Euler (transform.localRotation.x, DoorCloseAngle, transform.localRotation.z); // Dampen towards the target rotation transform.localRotation = Quaternion.Slerp(transform.localRotation, target1, Time.deltaTime * smooth); } if(enter == true) { if(Input.GetKeyDown(defined_key)) { open = !open; } } } //Activate the Main function when player is near the door void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { //Debug.Log("Trigger Enter"); (enter) = true; } } //Deactivate the Main function when player is go away from door void OnTriggerExit (Collider other) { if (other.gameObject.tag == "Player") { //Debug.Log("Trigger Exit"); (enter) = false; } } //@youtube.com/user/maksimum654321 }
  9. In my game I am attempting to do a simple parkour system. This system includes a rectangular detection collider in front of the player, and that is a trigger. When the game detects that the trigger hits something, then the game shoots out a raycast to see if the object is short enough to climb over. For some reason, the trigger only detects collisions that is the right size, that is, not an object too short, and not an object that is too tall. Is there a way to fix this? Here is a picture of a 'just right' size object of which the game can actually detect: Here is one of an object that is too tall: And similar outcomes appear for objects that are short, like the one to the left of the green cube in the 'just right' picture. I sadly cannot upload a screenshot of that because of UA's restrictions. Here is the script that I am using for the 'detected' variable: #pragma strict var detected : boolean = false; function OnTriggerStay(other : Collider){ if(other.gameObject.tag != "Player" && other.gameObject.tag != "NPC"){ detected = true; } } function OnTriggerExit(other : Collider){ if(other.gameObject.tag != "Player" && other.gameObject.tag != "NPC"){ detected = false; } } Any help is appreciated, -william9518
  10. Hi! I'm new of this forum and i start immediatly with a complex question... I have a scene (an hangar) with a standard First Perso Controller and a model (named Drone_1) in witch i enter by this script: static var inTrigger : boolean = false; static var inside : boolean = false; public var PlayerCamera : Camera; public var Player : Transform; public var moveSpeed : float = 10f; public var turnSpeed : float = 50f; static var exited : boolean = false; public var customSkin : GUISkin; static var showLabel : boolean = false; function OnTriggerEnter() { inTrigger = true; showLabel = true; } function OnTriggerExit() { inTrigger = false; showLabel = false; } function Update() { curPos = transform.position; if(inTrigger) { animation.Stop("Drone Waiting"); if(Input.GetKeyUp(KeyCode.U)) { PlayerCamera.gameObject.active = false; Player.gameObject.active = false; PlayerCamera.GetComponent(AudioListener).enabled = false; this.GetComponent(AudioListener).enabled = true; showLabel = false; inside = true; Debug.Log("Entered"); } else if(Input.GetKeyUp(KeyCode.E)) { this.GetComponent(AudioListener).enabled = false; PlayerCamera.gameObject.active = true; PlayerCamera.GetComponent(AudioListener).enabled = true; Player.gameObject.active = true; Player.position = curPos; Player.position.z += 5; inside = false; exited = true; Debug.Log("Exited"); } } if(!inTrigger && !exited) { animation.Play("Drone Waiting"); } if(inside) { if(Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W)) transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime); if(Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S)) transform.Translate(-Vector3.forward * moveSpeed * Time.deltaTime); if(Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A)) transform.Rotate(Vector3.up, -turnSpeed * Time.deltaTime); if(Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D)) transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime); } } function OnGUI () { GUI.skin = customSkin; if(inTrigger && showLabel) { GUI.Label (Rect ((Screen.width - 600)/2, (Screen.height - 40)/2, 600, 40), "Press U to enter, E to exit!"); } } As it can be seen when i'm "inside" i can play around with the Drone_1 that has attached a camera with SmootFollow script attached. The problem is: i used a Sphere Collider in the Drone_1 model that is Trigger to let the label appear and disappear. When i push U and go inside the Drone it passes through all the objects of the scene... I've tried to add even a Box Collider to the drone without trigger and to attach a rigid body component to an object but it doesn't work...drone still pas through. Help plz!
  11. I have a problem with triggers. when the object touch the trigger the script doesn't work. Trigger = Cube with Mesh Collider and TriggerMode = on Object to collide = My .fbx model with normal Mesh Collider Script: function OnTriggerEnter () { Application.LoadLevel(2); } --------------------------------------- I'm sure i did something wrong on Colliders but not in the script.
  • Create New...