Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Guildenstern · Feb 19, 2010 at 01:34 PM · collisionrigidbodybulletgunshell

Rigidbody of empty bullet shell collision problem.

Hi, Im quite new to unity (started about a month ago) and Ive been working on a mock up of a FPS using unity primitives to help me learn the ropes before I go into anything major. So far Ive created some basic movement controls and a pistol that shoots bullets. The problem Im having is that when the gun fires the bullets I also made it eject a small cube with a rigid body component to represent an empty shell, but for some reason the shell passes through the floor (a flat plane with a mesh collider).

This person http://answers.unity3d.com/questions/2666/rigidbody-sphere-falls-through-collider-plane sounds like they had a similar problem, but if I scale cube that represents the shell to 1,1,1 it works but makes it half the size of the character and if I scale everything else to match it causes everything to run very slowly.

Another problem Im having is that if the character is moving while he shots it adds way too much force onto the rigid body causing it to behave oddly. For example, the shell flies out the left side of the gun after I instantiate it (Rigidbody. velocity = transform. TransformDirection(Vector3 (-1,0,0)); ) to simulate the force of the ejection. But if Im strafing left at the time it sort of cancels out the initial force of the shell causing it to fall through the gun or appear to fly right.

Im really sorry if this doesnt make much sense, I have dyslexia so I find stuff like this exceptionally difficult.

Is there any way I can make this work or should I give up on it?

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 Guildenstern · Feb 19, 2010 at 01:34 PM 0
Share

Hears an image of the game, dont know if this helps it make any more sense.

http://tinypic.com/view.php?pic=np2vpz&s=6

2 Replies

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

Answer by jonas-echterhoff · Feb 19, 2010 at 04:25 PM

The reason you shell is falling through the floor is probably that it is too small to detect the collision. In one frame it's fully above the floor, in the next frame it's fully below the floor, it never touches it.

We are working on adding features to solve this in an easy way, but for now, you'll have to work around this. You could manually check for collisions, by storing the position of the bullet each frame in a script, and then do a Raycast from the old position to the new one, to see if it passed through anything on it's way.

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 Guildenstern · Feb 20, 2010 at 12:19 PM 0
Share

Thanks I will give that a try!

avatar image
0

Answer by Tuti · Jul 03, 2010 at 10:29 PM

About your question #2: You need to set ignore collisions between your gun shells and your character. The easiest way to do that is:

  • First set the tag and layer of your gun, character and bullet shells to be tha same, i.e "Player".

  • Use this script when you are moving, shooting or using anything that is detecting collisions. Look at this example:

    void Start() {

    // Add objects's own layer to mask
    mask = 1 << gameObject.layer;
    // Add Igbore Raycast layer to mask
    mask |= 1 << LayerMask.NameToLayer("Ignore Raycast");
    // Invert mask
    mask = ~mask;
    

    }

    ! Hope that helps!

    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

    1 Person is following this question.

    avatar image

    Related Questions

    Bullet case lagg & collision problem 2 Answers

    Collision misses - possibly not bullet through paper! (now with video) 1 Answer

    bullet desent seem to apear (javascript) 0 Answers

    Rigidbody bullets won't spawn at gun barrel... 2 Answers

    Hinge Joints Interfering with each other 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