Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by nasirs001 · Aug 30, 2015 at 03:36 PM · collisioncollidercollision detectiontriggers

Trouble with collison and trigger's

So here's my problem. I have a sphere with a collider and I want it set up so that when the player walks through the sphere it instantiates an object and the object plays animation that basically makes the object appear to be falling on the player. Then I want a collider in the object and to make it so that if the object actually touches the player then they get deleted but if it doesn't then they can continue.(I'm gonna make it load a different scene if it touches them but this is for testing purposes). Now the way I have it set up is that way exactly with two scripts for execution. One inside the sphere to instantiate the object and another inside the actual object to detect if the player is touched by the object. The problem I'm facing though is that the player get's deleted as soon as they touch the sphere and has no time to run from under the object. I applied root motion to the animation( just in case that information is relevant). Can anybody tell me what I'm doing wrong here?

here's the scripts

inside the sphere;

 using UnityEngine;
 using System.Collections;
 
 public class Squash : MonoBehaviour {
 
     public GameObject crush;
 
     void OnTriggerEnter(Collider Other){
         GameObject crushClone = Instantiate (crush);
         Destroy (crushClone, 2.0F);
     }
 }

inside the object:

 using UnityEngine;
 using System.Collections;
 
 public class Death : MonoBehaviour {
 
     void OnTriggerEnter(Collider Other){
         if (Other.tag == "Player") {
             Debug.Log (Other.gameObject.name);
             Destroy (Other.gameObject);
         }
     }
 }
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by justinyeh · Oct 21, 2016 at 12:51 AM

OnTriggerEnter is only for when a collider(not trigger) touch the trigger.

alt text

https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerEnter.html


螢幕快照-2016-10-21-上午84912.png (22.4 kB)
Comment
Add comment · Share
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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to change the color of an object when it collides with another object? 2 Answers

Prevent changing speed at collision 0 Answers

Collision between objects not being detected 0 Answers

Why is OnTriggerExit not firing? 3 Answers

Having the worst time making OnCollision work... Strange. 0 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