Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 AlbieMorrison · Oct 15, 2020 at 08:56 PM · collisioncolliderscollision2dbouncebouncing

Why does my bullet only bounce horizontally or vertically, even when it's fired at an angle

@MelvMay No matter what angle I fire my bullets at, they always bounce either horizontally or vertically. Why is this, and what can I do to fix it so the bullets bounce realistically? I've illustrated the problem in the image below, can someone help?

alt text

bouncingproblem.png (18.4 kB)
Comment
Add comment · Show 7
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 Eno-Khaon · Oct 15, 2020 at 09:10 PM 1
Share

In what context are the bullets bouncing? Is this driven by physics? Is it a scripted bounce (i.e. OnCollisionEnter())? Without more information on what you're currently doing, it's impossible to help, despite the behavioral description provided by your image.

avatar image TechnicPyro · Oct 17, 2020 at 10:18 AM 0
Share

To add on to what Eno-Khaon asked, is it an object based bullet or a raycast based bullet?

avatar image AlbieMorrison · Oct 29, 2020 at 07:57 PM 0
Share

@$$anonymous$$o-Khaon @TechnicPyro Sorry for the late reply, this is driven by the Unity physics engine (Rigidbody2D, Collider2D). It is an object, so collisions not raycasts. I do some checks and keep the bullet from spinning in OnCollisionEnter2D() and LateUpdate(), but I've tried it without those changes, and the problem still occurs.

avatar image Eno-Khaon AlbieMorrison · Oct 30, 2020 at 08:15 AM 0
Share

As some follow-up questions, then (Not necessarily that I need the answer to, but things to consider, more than anything else):

What shape(s) of collider(s) are you using on the bullets? Are the walls they're hitting square colliders? (If not, are they convex or concave?) Are they hitting the intersection of two adjacent wall panels? What physics material properties do they have? Are there any other adjustments made other than orientation correction in scripts?

There are numerous little possibilities that could have an influence on their interaction when left entirely to the physics engine. If the bullets are flying especially quickly, it could be a hiccup in resolving their new velocity. Even if not, it's easy to wind up with unexpected results.

It doesn't necessarily explain the results you demonstrated with the image, but without having experienced that behavior myself, I'm just trying to help think of as many possibilities as come to $$anonymous$$d. Of course, if anything stands out, just let us know!

avatar image AlbieMorrison Eno-Khaon · Oct 31, 2020 at 08:36 PM 0
Share

The bullets have triangular colliders (EdgeCollider2D), and the wall colliders are basically rectangular. I used the custom physics shape window and set the tolerance to lowest, so the colliders almost perfectly follow the shape of the sprite. I've attached a screenshot below. The problem is not that the bullets are hitting the intersection of different colliders, because I've tested multiple hit points and angles. The map and the bullets are two different physics materials: the map has a friction of 100 and a bounciness of 0.05, and the bullets have a friction of 0.4 and a bounciness of 0.9. And no, I don't make any other adjustments in scripts. It's all up to the physics engine.

One answer I thought of could be that the bullet is getting too far into the wall before it senses the collision, so it rebounds straight out of it. I will try lowering the fixed timestep, and seeing if that helps.

Thank you!

alt text

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by rubcc95 · Nov 05, 2020 at 10:19 PM

Are you using transform.position in order to move your bullet?

Think about use physics engine and some Physics material.

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

213 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to optimize a lot of colliders? 1 Answer

Tilemap collider doesn't appear 1 Answer

How to tell if a 2D object is in a certain area 2 Answers

Collision point problem 1 Answer

2D Reflect(bounce) With Rotation 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