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 clanssd · Jan 22, 2012 at 03:22 AM · animationcollisionrigidbodycharactercontroller

Collisions with an animated character

Hello there,

I apologize if this is a common question. I tried my best to search through existing questions for a good amount of time but couldn't find anything relevant.

I'm working on a 2.5D Castlevania style game. I've been trying to figure out the best way to implement attacks for the character and enemies without physically moving them forward to force a collision. They are mostly punch/kick animations with a limited number of attacks with melee weapons. The player character and enemies both use Character Controller components.

The only idea I've come up with so far is attaching colliders to the hand and foot joints of the models so that when they plays their animations, the colliders are driven forward through them, but this would require a separate script for a GameObject attached to the hands/feet correct (I'm working in C#)? Is this a sensible solution to this game mechanic? Is it possible to have a mesh collider that moves along with animations? I've tried to do this, but the meshes all seem to be stuck in the T-pose.

I ask because I followed the Lerpz 2D tutorial's system for handling footsteps sounds and particles, and I thought it was great while setting up my intro stage but it's becoming rather tedious to have to add in the scripts for every surface, even while using prefabs because the levels I'm designing after that are rather large and have a lot of unique surfaces.

Thanks for reading and I hope someone can suggest a more efficient method.

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
0

Answer by Kaze_Senshi · Jan 22, 2012 at 01:41 PM

Well, I am doing a simple 2.5d game too. In my game I use something like:

  1. Create a empty object;

  2. Attach in this object a script with only a Gizmos function;

  3. Put a collider in this object;

  4. Attach the empty object in some enemy;

So the empty object works like a "hurting area", my character just need to have a "if" inside the collider detection.

 function OnTriggerEnter (other : Collider)
 {
 ...
     var enemyDamageDetector : EnemyDamageDetector = other.gameObject.GetComponent( EnemyDamageDetector );
     if( enemyDamageDetector )
     {
         SendMessage ( "DidHit", SendMessageOptions.DontRequireReceiver );
         return;
     }
 }

This way, it is just put the script where I want. You don't need to make the script more, only reuse it. I think that you can jump the step 1 and put the script in the joint of the knuckles of your character or wharever.

Comment
Add comment · Show 2 · 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 clanssd · Jan 24, 2012 at 02:13 AM 0
Share

Thanks for the answer. How do you prevent accidental collisions? When my character runs, her hands stick out pretty far and I don't want that to cause enemies to get damaged just by running into them. Just turn off the collider component when the character isn't attacking?

avatar image Kaze_Senshi · Jan 24, 2012 at 03:18 AM 0
Share

Oh yeah, In my game you can damage enemies doing a "piercing dash". So when I press the button "fire2", I turn on one boolean "isDashing" and when its time ends, I turn it off. The if code becomes something like:

(...) if( enemyDamageDetector && player.isDashing() ) {Hurt enemy code}

In your case, I think you will want to damage enemies only when some specific animation is playing. I think is something like:

(...) if( enemyDamageDetector && (animation["falconpunch"].enabled == true)) ) {Hurt enemy code}

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to have other (any) Objects smoothly push a Character Controller? 1 Answer

Export Animations From Unity3D into Blender? 1 Answer

How to stop an animation on collision 0 Answers

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

Physics goes crazy when rigidbody collides with moving character controller 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