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 Lord_Arcanis · Apr 02, 2017 at 09:15 PM · c#collision detectiontriggerscollision2d

Can't get Collision to detect triggers in unity 2d

I've been trying for a while to get the players collision to be detected against the objects but alas nothing has worked, and scrubbing through forum responses hasn't helped either. Either I have made a meager mistake or am doing something entirely wrong.

I have a player that has a rigidbody2d, is Dynamic (I've tried making it kinematic and using full kinematic as well) and is simulated. Here is a picture: http://imgur.com/u2y9CfE

The Objects that it is colliding with have these settings: http://imgur.com/EZEXSFd Yes, I've tried not having a rigid body on them, and also have set them to Use Full Kinematic before as well when I do have them as a kinematic rigid body. It makes no difference, I still get no input on collision.

For the code for movement I've tried having it move through rb.Addforce and translating the objects position, both through fixed update.

I've checked the collision Matrixes and it seems to be in order as well, but here is a picture of that in case it may be messed up: http://imgur.com/kcCnt12

The Script for detecting that is connected to the player is:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class RowCollider : MonoBehaviour
 {
     public static bool alive;
 
     void Start ()
     {
         alive = true;
     }
 
     void OnTriggerEnter2D (Collider2D other)
     {
         Debug.Log ("You Collided!");
         alive = false;
     }
 
     void FixedUpdate ()
     {
         Debug.Log (alive);
     }
 }


I really have no idea how to get this to work, I've tried so many things, please help :'(

Comment
Add comment · Show 1
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 Lord_Arcanis · Apr 02, 2017 at 09:16 PM 0
Share

Whenever the player object collides with the rows it just changes nothing, neither of the debug messages go off.

4 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Lord_Arcanis · Apr 04, 2017 at 11:58 PM

Guys my bad, Apparently the collider boxes all shifted up for some reason when i made them prefabs, I had no idea :'(.

Comment
Add comment · Show 1 · 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
avatar image guinoalaskapp · Jul 06, 2021 at 08:43 PM 0
Share

Thats also my problem on my game, Thanks :3

avatar image
0

Answer by Commoble · Apr 03, 2017 at 02:06 AM

You have that script attached to the player object, correct? That's your problem.

When a script has an OnTriggerEnter2D event function, that event is called when a trigger collider on the same object as the script is entered by another object (not when the script's object enters a trigger collider). You need to put your trigger enter function on the trigger area object, not the player object.

Comment
Add comment · Show 1 · 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
avatar image Lord_Arcanis · Apr 03, 2017 at 10:32 PM 0
Share

Doesn't change a thing, Alive still never gets set to false and a the message "You Collided" never shows up.

avatar image
0

Answer by Lord_Arcanis · Apr 04, 2017 at 11:33 PM

Fixed things up a little, but hasn't changed anything: script : http://imgur.com/yyc4pl1

Object that is being collided against: http://imgur.com/NXmmqaU

Collision Matrix: http://imgur.com/DCsJpr5

Basically all that was changed was that the script was moved to the object being collided against rather than being on the player, and the player still has a dynamic rigid body and a box collider that isn't a trigger.

Yet it appears that the script won't even fire, regardless of anything to do with static variables it should at least send the debug message "You Collided!"

The player movement script, that is connected to the player works through rb. Addforce in a manner as so

rb.AddForce (transform.right * 1.5F);

If anyone knows what I'm doing wrong, please notify me.

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
avatar image
0

Answer by Max_power1965 · May 24, 2020 at 03:49 PM

I also had really a lot of problems when configuring the collision between game objects. After years I wrote every tips in this article https://gamedevelopertips.com/unity-collision-detection-2d/, I'm sure it'll be helpful if you want to set up properly you collider/triggers properly.

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

333 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 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 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 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 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 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Collisions not working in top-down RPG? 0 Answers

Lose Health when GameObject enters collider? (OnTriggerEnter) 2 Answers

How To how ?? 2 Answers

C# Activate Object on Collision with tag not working. 1 Answer

onTriggerStay detects collision even if is not colliding 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