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 chronicfail · May 30, 2013 at 11:30 AM · collisionrigidbodyweaponswitchlaunch

Stop player being launched on switch weapons

I don't think this has been asked before, I couldn't find it anywhere, but if it has, sorry.

I have made a script to swap weapons when the player is near a weapon on the floor and they press E. It works perfectly, but there is a problem with the part of the script that drops the original weapon. It works by disabling that weapon's scripts, enabling it's collider and unfreezing it's rigidbody. This works, but has the unwanted side effect of launching the player several hundred metres into the air. I think this is because when the weapons rigidbody and collider are enabled they are within the player, and push it. Of course, if they are not enabled, the weapon will just hover in the air, which is not what I want. Is there a way to avoid the player being launched whilst still dropping the old weapon on the floor?

Comment
Add comment · Show 5
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 chronicfail · May 30, 2013 at 11:45 AM 0
Share

If it makes a difference there is a capsule collider with a rigidbody attatched to the player so that they will be able to push rigidbodies

avatar image Tarlius · May 30, 2013 at 11:59 AM 1
Share

You could perhaps just make it "spawn" a few metres in front of the player?

Do you have a script that makes you move the player higher when a collider is "inside" him? I seem to recall a similar question a month or two back but forgot the cause ><

avatar image chronicfail · May 30, 2013 at 12:04 PM 0
Share

Thank you for your answer.

No, the player is just the default FPS controller with a capsule collider rigidbody parented to it. I have tried your idea and it works perfectly, but if their is a wall in front of the player it will disappear through it, and the weapon will be lost. Is their any way to make sure it stays this side of any colliders? maybe a rigidbody sweep test?

avatar image Daphoeno · May 30, 2013 at 01:44 PM 1
Share

follow this tutorial to make the gun visible : http://www.youtube.com/watch?v=bBrr-esgV8E

avatar image chronicfail · May 30, 2013 at 01:48 PM 0
Share

The problem is that the gun, when dropped, physically is going through walls/floor and falling into space. Sorry. i should have made that clear. Thanks for the link though, I have been looking for how to do that for ages!

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by dorpeleg · May 30, 2013 at 04:04 PM

You can use Physics.IgnoreCollision to make sure the weapon is not colliding with the player.

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 chronicfail · May 31, 2013 at 12:47 PM 0
Share

Thank you, I will try 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

16 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

Related Questions

Colliding Melee Weapons 2 Answers

Trouble with OnCollisionEnter and Exit 1 Answer

Rigidbody: how to get collisions for the current frame ? 0 Answers

Car dynamics? 0 Answers

Avoid Player bouncing when colliding with objects 3D 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