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 Superwayne · Aug 27, 2013 at 03:28 PM · collisiongravity

2D - no gravity when player jumps against wall?

Hello,

I made a 2D Jump'n'run but have a little problem: When the player jumps against a other solid cube collider (like a invisible wall - the border for the level - or the side of a platform) it just stays in the air as long as the player keeps moving in that direction. I use the standard gravity from unity and this is the movement script: rigidbody.velocity = new Vector3(moveSpeed * Input.GetAxis("Horizontal"), rigidbody.velocity.y, rigidbody.velocity.z);

I directly set the velocity instead of using AddForce because the latter of whom doesn't work that well when using standard gravity in 2D (the player sprite -cube collider- slows down hardly on the ground -more cube collider- while the player is to fast in the air).

The problem is that the horizontal collision between those colliders slows down the vertical velocity. I tried to use rigidbody.velocity = new Vector3... when the player horizontally collides with a wall but that doesn't fit because it isn't as smooth as the natural gravity.

Does anyone have another idea to solve this?

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 jethro0610 · Dec 07, 2013 at 06:17 AM 0
Share

In the 2D tutorial you can see the character get stuck on the wall just like you explained and I also have this problem.

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by robertbu · Aug 27, 2013 at 04:29 PM

I suspect you have not setup the Physic material on the colliders. If not:

  • You can get a sample set of Physic Materials by Assets>Import Package>Physic Materials.

  • Click on 'target' symbol opposite the 'Material' label on each Collider. Select a material. Start with Ice to get things to slide.

Note you can create your own Physic materials with the specific properties you need for your game.

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 Superwayne · Aug 27, 2013 at 06:21 PM 0
Share

Thanks! That was easier than expected and works great!

avatar image
0

Answer by xandermacleod · Nov 21, 2013 at 03:05 PM

Im having this problem although my issue is that the wall object is a floating platform that needs to rotate. (Think of a moving platform in Mario, but it rotates at certain points).

I have setup my square platform so that it has 4 separate custom colliders (1 per platform edge, that doesnt touch the other edges), so that I can have icy-walls but a normal top (so that the hero can run along it without it being slippery).

But the moment my platform rotates, if the player jumps into one of the sharp corners, he sticks in place in the same way.

Any advice?

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

18 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

Related Questions

How do I “freeze” an object after a collision? 3 Answers

How to get movable/pushable cubes right? 0 Answers

Spline Interpolator + FPS Walker? 0 Answers

Cube starts shaking when placed on a giant sphere 1 Answer

Sphere disappears!!!!! I downloaded 3D model assets from web and made a "decoration" game object...... 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