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 /
avatar image
0
Question by SirOrange · Oct 21, 2017 at 12:59 PM · collision2d game2d-physics

Why is my character not colliding with other objects.

This is the code i am using to run a 2d game like "The Escapists", but my character has a collider on him and does not seem to be colliding with other objects. This is in a 3d environment. Thanks. using System.Collections; using System.Collections.Generic; using UnityEngine; public class TemporaryMove : MonoBehaviour { public float movementSpeed = 10; public GameObject Right; public GameObject Left; public GameObject Up; public GameObject Down; // Use this for initialization void Start () { Down.SetActive (true); Right.SetActive (false); Left.SetActive (false); Up.SetActive (false); } // Update is called once per frame void Update () { if (Input.GetKey(KeyCode.D)) { transform.Translate (Vector3.right * movementSpeed * Time.deltaTime); Down.SetActive (false); Right.SetActive (true); Left.SetActive (false); Up.SetActive (false); } if (Input.GetKey(KeyCode.A)) { transform.Translate (Vector3.left * movementSpeed * Time.deltaTime); Down.SetActive (false); Right.SetActive (false); Left.SetActive (true); Up.SetActive (false); } if (Input.GetKey(KeyCode.W)) { transform.Translate (Vector3.up * movementSpeed * Time.deltaTime); Down.SetActive (false); Right.SetActive (false); Left.SetActive (false); Up.SetActive (true); } if (Input.GetKey(KeyCode.S)) { transform.Translate (Vector3.down * movementSpeed * Time.deltaTime); Down.SetActive (true); Right.SetActive (false); Left.SetActive (false); Up.SetActive (false); } } void OnCollisionEnter(Collision collision) { Debug.Log ("Hit"); if(collision.gameObject.CompareTag("Wall")) // or if(gameObject.CompareTag("YourWallTag")) { Debug.Log ("Hit"); } } }

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by surajsirohi1008 · Oct 21, 2017 at 03:30 PM

Make sure "isTrigger"is unchecked of the collider.

Comment
Add comment · Show 2 · 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 SirOrange · Oct 21, 2017 at 06:49 PM 0
Share

it is and nothing is working

avatar image SirOrange SirOrange · Oct 21, 2017 at 06:49 PM 0
Share

same as before

avatar image
0

Answer by bolkay · Oct 21, 2017 at 09:14 PM

@SirOrange.. See to Rigidbody.

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 Petroglyph · Oct 23, 2017 at 11:04 PM

Not sure about your code, but as bolkay mentionned, you need to add a Rigidbody to your moving object. Colliders on their own are meant to be static and do not trigger each other. Make sure you check the isKinematic option on your Rigidbody, to allow you to move it by code as you seem to be doing.

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

124 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

Related Questions

Problem with collision with two colliders simultaneously in Unity 2D 1 Answer

Unity 2D Collider Safe Sizes 0 Answers

2D collision not registering 1 Answer

2D Detect collisions of a 2D block only on left/right (not top/bottom) 0 Answers

How can I make sure triggers or collisions are never skipped even for high speeds? 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