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 dragonking300 · Nov 17, 2016 at 04:44 PM · c#scripting problemscripting beginner

My OnCollisonEnter doesn't detect collison.

EDIT: I forgot to mention I use the roll-a-ball tutorial movement to move my sphere if that helps

I've spent hours trying to find a solution to this problem. The tags are in place. I try to move OnCollisonEnter to void Update() and it just creates tons of error no matter what I enter or remove. Please don't be cryptic with your answer or to look more into it because I've done that for 6 hours all ready.

using UnityEngine; using System.Collections;

public class Jump : MonoBehaviour { public bool OnGround; private Rigidbody rb;

  void Start()
  {
      OnGround = true;
      Debug.Log("OnGround set to true in Start");
      rb = GetComponent<Rigidbody>();
  }
 
  void Update()
  {
      if (OnGround)
      {
          if (Input.GetButton("Jump"))
          {
              rb.velocity = new Vector3(0.0f, 10f, 0.0f);
              OnGround = false;
              Debug.Log("OnGround set to false in Update");
          }
          else
          {
          }
      }
  }
 
  void OnCollisonEnter(Collision other)
  {
      Debug.Log("Collision entered with tag named: " + other.gameObject.tag);
 
      if (other.gameObject.CompareTag("Ground"))
      {
          OnGround = true;
          Debug.Log("OnGround Set To true in OnCollisionEnter, collided with tag: " + other.gameObject.tag);
      }
      else
      {
          OnGround = false;
          Debug.Log("OnGround Set To false in OnCollisionEnter, collided with tag: " + other.gameObject.tag);
      }
  }

}

Comment
Add comment · Show 6
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 hexagonius · Nov 17, 2016 at 09:40 PM 0
Share

which if your debugs are you getting?

avatar image dragonking300 hexagonius · Nov 17, 2016 at 09:46 PM 0
Share

In debug menu it starts off a as grounded == true then when it jumps it switches to false but the collision with the "ground"(a plane with the tag ground) doesn't switch the grounded value back to true

avatar image hexagonius dragonking300 · Nov 17, 2016 at 10:04 PM 0
Share

what I meant was which of the Debug.Log messages did you reach?

Show more comments
avatar image TreyH · Nov 17, 2016 at 09:45 PM 0
Share

Does your person just go through the ground then?

And both are 3D objects?

Are either of them flagged as a Trigger? Could you screenshot your physics layer settings?

avatar image dragonking300 TreyH · Nov 17, 2016 at 10:06 PM 0
Share
  1. no, the sphere collides with the ground

  2. yes, and yes they are and the sphere has a rigidbody

  3. what do you mean flagged as trigger? If OnCollisionEnter acts as a trigger the sphere is the trigger also how do I use physics layer settings?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by dragonking300 · Nov 17, 2016 at 10:32 PM

Update: so apparently setting the sphere to the ground tag as well makes it magically work .-.

Could you tell me why that is?

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 hexagonius · Nov 18, 2016 at 06:21 PM 0
Share

then the question is where did you attach the script.If it now works it's not in the sphere but the other way around

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

271 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

Related Questions

HELP! How to make Update function start after delay? C# 2 Answers

How to make a thrown object land on a certain point e.g a thrown spear landing on its tip 0 Answers

Problems with respawning using a very simple script 1 Answer

Having trouble deleting objects from a list after they reach a certain scale. 0 Answers

Rotate Player 90 degrees about its Y axis relative to the mouse being dragged between two angles 1 Answer


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