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
1
Question by boddole · Oct 24, 2014 at 02:44 AM · collisionphysicsvector3

Question on Vector3.Reflect()

Hello everyone, I'm trying to get a specific result from a collision using Vector3.Relfect() which does not seem to be its default behavior:

I've seen Vector3.Reflect(), but In my case, I'm simulating (sort of) a cannon shell impacting iron armor, so I'm looking for more of a reflection vector like in my image below (a much flatter angle, where the shell almost "slides" along the armor after it deflects).

If anyone could show me a way of doing this or what math concepts I would need to get the result I'm after, I would greatly appreciate it.

alt text

angleexample.jpg (80.5 kB)
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
2
Best Answer

Answer by Bunny83 · Oct 24, 2014 at 03:12 AM

Well, you could simply reflect it and then subtract a fractional part of the projected vector along the surface normal (well that sounds more complicated than it is :D)

 Vector3 normal;
 Vector3 incomingVelocity;

 var reflected = Vector3.Reflect(incomingVelocity, normal);
 var v = Vector3.Project(reflected, normal);
 var result = reflected - v * 0.9f;


This would take away 90% from the distance of the reflected vector to the surface. So just imagine point R in your diagram goes straight downwards. If you use 1.0 instead of 0.9 the point R will be on the surface.

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 Bunny83 · Oct 24, 2014 at 03:25 AM 1
Share

Just to explain what this actually does. This will keep 100% of the veloocity that is parallel to the surface but reduces the bounce of the velocity that is perpendicular to the surface.

That means if the inpact is straight down along the normal it won't move to the side since it doesn't have any velocity in that direction. It will bounce off back to where it's co$$anonymous$$g from but way slower (only 10%)

If the inpact is at a narrow angle the shell will almost slide along the surface with almost the same speed.

avatar image boddole · Oct 24, 2014 at 04:21 AM 0
Share

Interesting, I'll look into this. Thanks.

Update: Having a lot of fun with this, could not have done it without you.

avatar image
0

Answer by nark · Jan 10, 2017 at 07:43 AM

The second paramater need to be normalized.

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

29 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 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 to avoid objects bouncing and overlapping after collision? 0 Answers

Concave rotation Collision problem 3 Answers

Destroy On Collision 4 Answers

Detecting collision and fixing position odd behaviour. 0 Answers

C# GameObject is not detecting collision with Character Controller 2 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