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 Pong · Apr 09, 2011 at 12:39 PM · colliderattackmeleecombat

Melee attack comblat

I want to make a melee comblat. Now I used the OnControllerColliderHit to work between my character and enemy. But the problem before the script is counting in many time when my character is playing the attack animation. So now I but the cool down timer to prevent it. Finally is ok, but now the problem is the animation between the combo. Sometime the enemy hitted animation will play when I start the combo 2, but sometime will not. What is the problem? Is it the script or animation problem?

below is the script I put

function OnControllerColliderHit (hit : ControllerColliderHit) { var myFPSPlayer : CharacterController; myFPSPlayer = gameObject.GetComponent(CharacterController); if (attackid > 0) { attackid -= Time.deltaTime; } if (attackid < 0) attackid = 0; if (myFPSPlayer) Debug.Log ("myFPSPlayer component found"); if (hit.gameObject.tag == "Enemy" && Input.GetKeyDown("j")) { if (attackid == 0) { Debug.Log ("gameObject with tag evil found"); ApplyDamage(hit.gameObject); attackid = coolDown; } } else { Debug.Log (hit.gameObject.name+" don't have tag evil, his tag is "+hit.gameObject.tag); } }

function ApplyDamage(someObject : GameObject) { var healthScript = someObject.GetComponent("HealthScript"); if (healthScript != null && animation.IsPlaying("attack1") ) { someObject.animation.CrossFade("hit",0.2); healthScript.Health -= 10; Debug.Log ("A"); } if (healthScript != null && animation.IsPlaying("attack2") ) { someObject.animation.Play("hit"); healthScript.Health -= 10; Debug.Log ("B"); } if (healthScript != null && animation.IsPlaying("attack3") ) { someObject.animation.Play("hit"); healthScript.Health -= 10; Debug.Log ("C"); }

if (healthScript != null && animation.IsPlaying("attack4")) { someObject.animation.CrossFade("die",0.2); healthScript.Health -= 10; Debug.Log ("D"); } }

Also, if I want to work melee comblat, I use colliderhit to do or use physics.raycast to do is better?

Can someone help me

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
2

Answer by Unamine · Apr 09, 2011 at 01:32 PM

See videos of Burg Zerg Arcade, it teaches the basics of this, plus a full RPG, here's the link:

http://www.burgzergarcade.com/hack-slash-rpg-unity3d-game-engine-tutorial

5. Unity3d Tutorial - Melee Combat 1/3

6. Unity3d Tutorial - Melee Combat 2/3

7. Unity3d Tutorial - Melee Combat 3/3

Comment
Add comment · Show 3 · 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 Pong · Apr 10, 2011 at 05:16 AM -1
Share

I have read the tutorial before... but I dun know how to change it into javascript. Or make the target to be tag"enemy"...

avatar image FizzyBear Pong · Apr 15, 2012 at 09:39 PM 0
Share

$$anonymous$$aking the tag is simple, just go to the Inspector, underneath the object name (top right) says "Untagged", just change that into "Enemy".. :)

avatar image Lost_C4 · Feb 05, 2013 at 04:07 PM 0
Share

With C# scripts. -.-

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

I'm still having Trouble with this AI script 2 Answers

This melee damage detector won't work... 1 Answer

Melee Combat 1 Answer

Ai Zombie Melee Attack script. 5 Answers

character area attack problem 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