Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Nackles42 · Dec 29, 2017 at 06:28 AM · jumpplatformertriggerscollision2d

Trigger not being activated?

[2D] So, I'm working on a platformer-type game with jumping and stuff. I have the jump worked out, and it works just how I want, but I need to find out a way to refresh the jumps upon landing. I made an invisible box with a Box Collider 2D that is a trigger. However despite this, my script has a hard time seeming to be able to figure out when it is grounded or not. It seems like my OnCollision's are not being triggered ever, as the print always says false. Any tips?

alt text (the 'jump arc' is the one I like, 'jump arc try 2' was an attempt to see if I could fix it.)

I'm really stuck on this, so if you guys could help me out, that would be much appreciated.

help.png (31.3 kB)
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
4

Answer by MightyBearGameStudio · Dec 29, 2017 at 06:49 AM

 void onCollisionEnter () {
 
 
 }

should be changed to:

 void OnCollisionEnter(Collision col) {
 
 
 }
 
 



same with the oncollisionstay and exit.

Comment
Add comment · Show 4 · 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 Nackles42 · Dec 29, 2017 at 06:51 PM 0
Share

Hmm, I'm not sure I understand. I think I did it right (I tried it both with and without checking for tag, which my trigger definitely has) and it still always prints that I am not grounded, and also restricts my jump (this jump is just a testing one and therefore isn't an arc).

alt text

help2.png (14.4 kB)
avatar image MightyBearGameStudio Nackles42 · Dec 30, 2017 at 03:07 AM 2
Share

The OnCollisionEnter has to have a capital O, it's very case sensitive.

avatar image MightyBearGameStudio · Jan 02, 2018 at 06:32 AM 1
Share

Also, you need the "Collision col" in the parenthesis of the OnCollisionEnter void, or else it doesn't work. Tell me if it works!

avatar image Nackles42 MightyBearGameStudio · Jan 28, 2018 at 04:54 AM 0
Share

I finally got it to work! The issue ended up being so dumb in retrospect. I didn't realize I had to make sure it was a 2D OnCollision. Once I changed them to OnCollisionEnter2D(Collision2D col) it worked! Thank you for your help!

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

75 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

Related Questions

Character on a moving platform slows down 1 Answer

How to fix Jump problem with 2d Platformer Unity demo game? 0 Answers

Why my variable istn't always used? 2 Answers

Get callback when trigger enabled inside other collider 2 Answers

2D Triggers and Collisions not working as expected. 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