Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Thesaurus1233 · Feb 03, 2015 at 09:54 PM · errorontriggerentertagsfix

Problem with OnTriggerEnter

Please if someone could help me with this, i tried everything and nothing worked.

In the game I'm making in order to call a dead state I'm using a box collider to track if the player enters in a particular zone, but the problem is that it only tracks it if I'm pressing any of the a,s,d or w keys in the keyboard.

This is the code.

The OnTriggerEnter is call in line 48.

 using UnityEngine;
 using System.Collections;
 
 public class PlayerManager : MonoBehaviour
 {
     public bool Death = false;
     public bool Alive = false;
     public bool Muerto;
     public GameObject Generador;
     public GameObject StartButton;
     public CharacterMotor Motor;
     public static PlayerManager Instanse;
 
     // Use this for initialization
     void Start()
     {
         Instanse = this;
     }
 
     // Update is called once per frame
     void Update()
     {
         if (gameObject.transform.position.y <= -3.5f)
             Death = true;
 
         if (!Alive)
             Generador.transform.position = new Vector3(0, -0.57f, -4.12f);
 
         if (Death)
         {
             Generador.transform.position = new Vector3(0, -0.57f, -4.12f);
             GenerateManager.Instante.BeforeObject = GenerateManager.Instante.Spawn;
             Motor.canControl = false;
             StartButton.SetActive(true);
             CameraMovement.Instanse.CanMoveCamera = false;
             gameObject.transform.position = new Vector3(0.46f, 1.102971f, -6);
             Camera.main.transform.position = new Vector3(-0.07402526f, 12.0031f, -1.937099f);
             foreach (GameObject gm in GenerateManager.Instante.BloquesGenerados)
             {
                 Destroy(gm);
             }
             GenerateManager.Instante.BloquesGenerados.Clear();
             Death = false;
 
         }
     }
 
     void OnTriggerEnter(Collider other)
     {
         if (other.gameObject.tag == "Generador")
             GenerateManager.Instante.DoGenerate = true;
         if (other.gameObject.tag == "Muerte")
         {
             Alive = false;
             Death = true;
         }
     }
 }

If someone can help me fix this i will be very grateful.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image PrisVas · Feb 04, 2015 at 07:28 PM 0
Share

What do you mean by only pressing a,s,d or w? if you use the arrows it doesn´t trigger?

If you want it to check if the player entered and is still there use OnTriggerStay.

avatar image Mmmpies · Feb 04, 2015 at 07:42 PM 0
Share

Pretty sure they mean when the the characters moving. Try doing OnTriggerEnter on both the player and the object that has the trigger. See if when it doesn't trigger on one it triggers on the other.

avatar image cgeopapa · Feb 04, 2015 at 07:50 PM 0
Share

Where is the script attached? It should be on the player!

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Ontriggerenter not working 1 Answer

Where is this (-1) coming from in my change level script? 1 Answer

how to fix third person 1 Answer

NullReferenceException Error 2 Answers

Null Reference When Calling OnTriggerEnter? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges