Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 robmpreston · Aug 03, 2013 at 10:39 PM · 2dcollision

Collision for a 2d Top Down RPG using 2d Toolkit

Hello,

I am in the process of moving to Unity from my own custom XNA engine. I am a bit confused about the built in collision handling. What is the best way to use this with a character controller on a top down 2d JRPG?

I did some simple tests and the collisions seem to work at times... other times I get strange results or the sprite even disappears from the map altogether. Just wondering what the best way to handle this is. Should I write my own handler from scratch?

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
0
Best Answer

Answer by Peter G · Aug 03, 2013 at 11:53 PM

Collisions should work just fine. The only thing I would recommend would be giving your sprite colliders real depth (even if the sprites don't have any) . If the colliders are too thin your character could pass through them, or walk over them.

Without knowing a little more about your set up its hard to know what's going wrong. Do the colliders have rigidbodys? Did you use Controller.Move()

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 robmpreston · Aug 04, 2013 at 12:03 AM 0
Share

Hi Peter,

I just checked and I noticed that when I move against a collision, the player sprite begins moving away into the z-direction until he goes out of view. How can I use Controller.$$anonymous$$ove() so he will never push away from the collision into the z-direction? X and Y would be fine.

avatar image Peter G · Aug 04, 2013 at 01:54 AM 0
Share

The easiest way is just to reset the objects z-position every frame.

 function Update () {
 
      transform.position.z= 0
 
 }

Or whatever height the character is at.

avatar image robmpreston · Aug 04, 2013 at 02:20 AM 0
Share

Thanks Peter, found that elsewhere, seems to work. The only thing I'm confused about now is when I collide with a tile on the map, and I keep holding the arrow key in that direction it slowly keeps moving in that direction, into the collision. Any idea why that would happen?

avatar image robmpreston · Aug 04, 2013 at 03:18 AM 0
Share

Never$$anonymous$$d got it - had to change the collider depth in my spritesheet within 2d T$$anonymous$$

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

15 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

Related Questions

Pacman eating (destroying) pellets on collision! 0 Answers

Object collision triggering null reference at runtime when colliding with clone of itself after being childed. 1 Answer

Basics on 2d gameplay for a 2.5d Game 1 Answer

A node in a childnode? 1 Answer

need help please! 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