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 /
  • Help Room /
avatar image
0
Question by erayalakese · Aug 29, 2015 at 06:13 PM · collisioncolliderscollider2d

BoxCollider not blocking other object(s)

I'm really newbie , watched about 20 videos about and tried to do something. But I still have problems with collisions.

I'm working on 2D. I have a Sprite and a Cube. When I click to somewhere at screen, sprite is moving to that position. When sprite hit to cube, it should stop moving (when collision occured) , but instead it's passing through it.

Sprite has these components: alt text

Cube has this components: alt text

BallControl Script

 using UnityEngine;
 using System.Collections;
 
 public class BallControl : MonoBehaviour {
     
     private Transform tf;
     private Rigidbody2D rb;
     Vector3 mousePosition;
     void Start()
     {
         tf = GetComponent<Transform> ();
         rb = GetComponent<Rigidbody2D> ();
     }
     
     void Update ()
     {
 
         if (Input.GetMouseButtonDown (0)) {
             mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
             mousePosition.z = 0f; // Because we are working on 2D
 
             }
         transform.position = Vector3.MoveTowards(transform.position, mousePosition, 1.5f * Time.deltaTime);
     }
 }

Can you tell me why cube's Box Collider not blocking sprite? Should i add something like this to my BallControl script?

 void OnCollisionEnter(...)
 {
      // Stop moving
 }

ekran-resmi-2015-08-29-210814.png (57.1 kB)
ekran-resmi-2015-08-29-210726.png (65.1 kB)
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 erayalakese · Aug 29, 2015 at 06:37 PM 0
Share

Disabling kinematic and setting Gravity Scale = 0 solved problem but I have no idea , why this problem occurring and how these settings solved the problem.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by kisuke_snow · Sep 13, 2017 at 09:49 PM

You have a 2D Collider on the sprite and a 3D collider on the box. Put them in the same dimension and you are good to go.

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

29 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

Related Questions

2D colliders doesnt work with Gravity Scale = 0 0 Answers

Tilemap Collision 2D colliding with ground. 0 Answers

my colliders don't work properly 2 Answers

boxCollider2D don't move with a tile object 1 Answer

RigidBody Collisions Detect 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