• 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
2
Question by Dot45 · Jul 19, 2011 at 12:27 AM · slideramp

Sliding slope or ramp

I have a problem with send a character (ball in this picture). I want it to slide along a way that player created via dragging mouse like in the picture. i give a ball with rigidbody and add force to it when instantiate.

http://img.photobucket.com/albums/v204/pigman8857/Sliding.jpg

the problem is when the ball collide with the ramp that we created, it has bouncing, not go along the way smoothly and it didn't go high like in the picture but fall down. How do i do??

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
2

Answer by aldonaletto · Jul 19, 2011 at 03:24 AM

Set the Physics.gravity to point down to the ground: if in your game the ground is at the XY plane, use Physics.gravity = Vector3(0, 0, 9.8);, for instance. In order to reduce the bouncing, try different physic materials for the ball and for the ground/walls, or just adjust their characteristics:

  collider.material.bounciness = 0; // zero the bounciness
Adjust also the force - too high, the ball may bounce excessively; too low, it may stop prematurely.
But remember: the physics engine try to reproduce a real physics system, so the ball will not do what you want, but just what it would do in the real world. In your drawing, for instance, the ball would follow the first wall as expected, but would bounce at the second wall and go to the left, returning to the first wall.

EDITED: I presumed that your game was 2D, the ball should run over a flat surface (the ground), and those blue pieces were walls - something like a pinball machine. In this case, the gravity should be perpendicular to your drawing.
But if the picture shows the vertical plane, then the gravity should point down (to this comment, for instance). You should not change gravity at each point, since it would affect every rigidbody in scene.
Supposing the drawing shows the XY plane, you don't need to change Physics.gravity; just set the bounciness of the ball and the blue pieces to zero, and set the ball rigidbody velocity directly instead of applying a force:

  rigidbody.velocity = Vector3(50, 0, 0);
This will make the ball start running at 50 units/s to the right, like in your drawing. Controlling the velocity directly is easier than setting a force, since you don't have to worry about mass and duration of the applied force. Try some different velocity values until you find the best one.
NOTE: Don't set the velocity at each update! Set it only once, at the ramp start, and let physics do the rest.
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 Dot45 · Jul 19, 2011 at 06:07 AM 0
Share

I have add ice physic material but it seems still has bounciness.

you said "Set the Physics.gravity to point down to the ground: if in your game the ground is at the XY plane, use Physics.gravity = Vector3(0, 0, 9.8);"

how do i set the gravity witch point to each plane

avatar image aldonaletto · Jul 19, 2011 at 10:31 PM 0
Share

I edited my answer to include other possibilities.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Problem with ramps in shaders 0 Answers

How can I make raindrops slide on inclide surfaces, but smash onto horisontal ones? 0 Answers

Sliding and gravity. 1 Answer

Sider Joint 2D in 3D 0 Answers

What's the best way to ramp slowmotion? 1 Answer


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