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 Jasozz · Oct 17, 2014 at 09:20 PM · collisionphysicsenemymelee

My sword pushes enemies around?

Literally just started using Unity yesterday, and I'm slapping together a little third person action game to learn the ropes and try to get a grip on C#.

I currently have a player that moves around correctly, and an enemy that is able to follow the player around.

I gave the player the ability to transition into an attacking animation when the player clicks LMB, and the enemy correctly detects when its been struck by the sword and plays a "damage" animation.

The only issue is that in order for the sword to detect collisions with the enemy, and in order for the enemy to use the NavMesh, I had to give it a RigidBody, and when the player's sword hits the enemy, it gets pushed around by the sword.

I had a little workaround where the enemy got RigidBody.isKinematic enabled briefly when it was hit, but this doesn't work all of the time.

I'm sure there's a much better way to handle this, but like I said, I'm new and would appreciate the help.

The player has a Character Controller, the sword bone of the model has a capsule collider that is parented by the sword, so it sticks to it, and the enemies have a RigidBody, NavMeshAgent, and Capsule Collider.

EDIT: to clarify, the player model itself pushes the enemy around; the sword is part of the player model.

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
Best Answer

Answer by mwbranna · Oct 17, 2014 at 10:17 PM

If you don't need the sword to bump anything around, you can use triggers. Triggers are like colliders except don't actually bump stuff, they just allow for use of the OnTriggerEnter() function and similar functions to detect overlapping objects. To make a collider a trigger, check the "Is Trigger" box in the collider in the inspector.

Collider manual page, with a section on triggers.

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 Jasozz · Oct 20, 2014 at 01:46 PM 0
Share

Ah, alright.

I made the sword's collider a trigger, and changed the code to onTriggerEnter ins$$anonymous$$d, but previously I had it set up as onCollisionEnter (Collision collision){ so that I could find which object it was colliding with, and that doesn't seem to work with onTriggerEnter; It throws the error:

"Script error: OnTriggerEnter This message parameter has to be of type: Collider The message will be ignored."

EDIT: Never$$anonymous$$d, I fixed it. Thanks for the 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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to stop my sword from hitting myself 2 Answers

Melee weapon collision inconsistent at low framerates 1 Answer

Problem with melee collision 3 Answers

Full Performance On Melee Combat 0 Answers

Shaking physics body container while preventing penetration 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