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 unityRookie · Jul 03, 2010 at 05:28 PM · fpscollisiondetection

Hand-Held Weapon Collision Detection Not Working (going through walls)

I'm working on creating a first person game where the FPC can carry weapons and attack with them (e.g. a sword). The issue I'm having is when I carry the weapon around (the weapon is a child of my FPC, and is in front of me, but not attacking), it goes through walls and other objects. I've tried using colliders on the sword, but these go through walls as well.

When I make the colliders triggers, they do correctly detect the other object. So I'm confused why when I make them solid colliders (not triggers), the FPC does not stop moving when the weapon hits the other object. Is there a way to carry weapons in front of you that have colliders on them and stop the FPC from moving?

I've looked at the FPS tutorial and others and know that I can shrink the sword object and put it 'within' my FPC radius, but then I run into the issue of when i attack with the sword, the enemy will have to be very, very close to me for the hit detection to work (using colliders/triggers).

Thanks.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by JonManatee · Jul 03, 2010 at 06:10 PM

You can't have the sword automatically drive a parent objects behavior (in a general sense, thats what inverse kinematics. You'll need to leverage scripting to get the desired behavior, especially because, as a rule, CharacterControllers exist outside the bounds of normal game physics.

You will have to have some sort of script on the sword that detects collisions, and have your walls and other barrier objects in a specific tag or layer that your script can check for. From there the script will need to inform whatever you have driving the CharacterController that it can't move any closer to the wall.

Alternately, the script could appropriately move the sword closer to the CharacterController, but you'll need someway to detect when the sword back to the appropriate distance from the player. Perhaps wrapping the sword with a larger trigger, so that when the collider touches the wall the sword is moved backward, but not so far that the trigger isn't touching the wall still. When the player moves far enough away that the trigger is no longer touching the wall either, you can move the sword back into place.

Those are my ideas, but I'm sure there are other solutions as well.

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 unityRookie · Jul 05, 2010 at 08:31 PM 0
Share

Thanks for the reply. I decided to try to go about it a different way and place a second camera on the weapon I'm carrying so and do culling so that the weapon is always visible, which has solved the through the walls problems. I still need to work on hit detection but that's where I'm out now. Thanks for you're help.

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

No one has followed this question yet.

Related Questions

FPS Character Controller collisions detection 1 Answer

Fps Arm moves fase 2 Answers

is there a way to get a mdl in untiy 1 Answer

FPSInputController and Character Animation 1 Answer

How i "import" variables? 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