• 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 OmegaVemon · Jan 10, 2011 at 08:13 PM · 2dcollision

Making 2d Games with Unity3d.

Ok, I am interested in creating a platformer game.

Now, I know that Unity can create 2d games, where my sprites are simply textures on planes etc and some help with Sprite Manager 2.

But I don't quite get it.

How do I check for collision between two planes? I mean... seriously...?

Naturally, there is gravity in my platformer game world. So objects like the player himself can fall.

If he hits a platform, won't his whole sprite suffer common collision effects like bouncing? Bouncing would cause the plane to, dunno, rotate or end up in a weird position, no?

Then my player runs... And hits a wall. Now there's another collision, the whole plane's Z position might increase and that means the player would fall to oblivion since all planes have 0 (or 1?) depth?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Eric5h5 · Jan 10, 2011 at 08:29 PM

You don't check for collisions with planes, you use box colliders or whatever else is appropriate.

Bouncing would cause the plane to, dunno, rotate or end up in a weird position, no?

No, you turn on Freeze Rotation. Depending on what you're doing, it might be better not use the physics engine at all, and just do your own.

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
1

Answer by poncho · Jan 10, 2011 at 10:08 PM

in the function update you can make the objects fix their xy position and rotation, making this objects to only work on XY planes code like,

gameobjectX.transform.position = new vector3(gameobjectX.transform.position.x,gameobjectX.transform.position.y,0);
//and to correct the rotation on x and y correct those values to make it 0, meaning no rotation on those
if(gameobjectx.transform.eulerAngles.x != 0)
   gameobjectX.transform.Rotate(new vector3(-gameobjectX.transform.eulerAngles.x,0,0);
if(gameobjectx.transform.eulerAngles.y != 0)
   gameobjectX.transform.Rotate(new vector3(0,-gameobjectX.transform.eulerAngles.y,0);

with position the objects just move left right up down and with the rotation the objects just rotate on the 0, 360 degrees you see from the front

hope this helps

thanks to eric for the correction

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 Eric5h5 · Jan 10, 2011 at 10:40 PM 0
Share

localRotation is a quaternion; setting the .z component won't do what you're expecting.

avatar image poncho · Jan 10, 2011 at 11:10 PM 0
Share

sorry this code i thought was the one, i checked my old codes, and used Rotate not localRotation, also the eulerAngles were needed to read the rotation of the object on 0-360 degrees thanks eric for the comment

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

I'd like some help with my health / shooting (collision detection) 1 Answer

Multiple collision areas within plane 0 Answers

Weapon System with collide detection (Helps with script pls)!!! 0 Answers

Need to get parent Object after collision 1 Answer

Modular Room System Similar to Mega Man 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