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 iraldir · Jun 09, 2012 at 11:26 AM · collisionballvectorbounce

Unrealistic bounce

Hi, i'm coding a minigolf like game, but i'm having difficulties with the bounce. Currently, i'm using a bounce material, but the problem is, when the ball has a really low angle, it will slide on the wall. I tried to then code myself a script, using a wall with a trigger, but I don't know how to get the "normal vector" of the wall. You see, wall can be vertical, horizontal, curvy, etc., and I can't (at least I don't want) create a script for each sitation. So is there a way to get the "normal vector" in a "onTriggerEnter" or a "onCollisionEnter", or can I create my own physic material to do so? Is there any other way?

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
0

Answer by whydoidoit · Jun 09, 2012 at 11:28 AM

Well you can get the contacts in OnCollisionEnter from the collision parameter and that gives you the normal of each contact point.

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 iraldir · Jun 09, 2012 at 02:26 PM 0
Share

So, I tried to make my own bouncing script, using the contacts in OnCollisionEnter, but results are quite specials.

Here is my code:

void OnCollisionEnter(Collision other) { Debug.Log("bounce");

 if (other.gameObject.tag == "bouncy")
 {

          velocity= Vector3.Reflect (gameObject.rigidbody.velocity,other.contacts[0].normal);
 }

 gameObject.rigidbody.velocity = velocity;

} Depending on the angle of the ball, it will work sometimes, and sometimes won't. And the speed of the ball changes as well, whereas i'm trying to keep the same speed (i'm in a space-like environnement, without frictions). So, some time the ball bounces, and some time it stucks on the wall. Any idea?

avatar image whydoidoit · Jun 09, 2012 at 06:26 PM 0
Share

Hmmm:

  • are you actually getting more than one contact?

  • can you try going back to the ordinary physics and reducing the $$anonymous$$imum bounce speed in the physics settings?

avatar image
0

Answer by iraldir · Jun 09, 2012 at 11:30 AM

that sounds promising, i'll try this, and give a feedback to you. Thanks

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 whydoidoit · Jun 09, 2012 at 11:31 AM 0
Share

Just one thing - on Unity Answers "Answer" means "Solution" and not "Reply" - there's an Add New Comment link hidden over on the right of the screen - use that rather than Answer as they get cleaned up when they are not a solution to the question :) Everybody does it first time :)

avatar image iraldir · Jun 09, 2012 at 02:16 PM 0
Share

Oh, my bad, sorry for that

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Enemy bouncing physics 0 Answers

Bounce when hitting wall 2 Answers

Unity2D Collision is bugged 0 Answers

Physics Collision problem(when ball enter to next ground) :( Seeking for solution from more than 1 month 1 Answer

SImple bouncing ball with pysics : wierd and not logical bounce 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