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 FrostHDD · Oct 31, 2012 at 01:19 PM · collisionmeleemmo

how should i go along making a melee system

im making a mmo i have some scripting language knowledge i can make some scripts, anyway how should i go along making a melee system what i thought i should do is make a function OnCollisionEnter and make it so when you press fire1 if an enemy with the tag enemy gets hit with the collider it gets damage taken from it i started a script but got lost can anyone please help

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 Montraydavis · Oct 31, 2012 at 02:08 PM

Well for one, you will need a bit more than what you have said unless you already have some of this done ! Here is a good starting point that should at least detect collision, and then notify the enemy that it has been hit by something . . . .

 On the Player weapon/hand/etc:
 
 function Update ( ){
 
    DoAttack  ( ) ;
 
 }
 
 function OnTriggerEnter ( collision : Collision)
 {
    if ( collision.collider.tag == "MonsterTag" )
    {
 
       collision.collider.SendMessage ( "DamageFactor", 83 ) ;
    
    }
 }
 
 On the enemy:
 class EnemyClass{
    var Health : float = 100 ;
    var Defense : flaot = 1.7 ;
 }
 
 var Enemy : EnemyClass ;
 function DamageFactor ( damage )
 {
    Enemy.Health -= damage * ( Enemy.Defensee / 10 ) ;
 }
 
 function Update ( )
 {
    //..your update code..
 }



As far as adding in multi-combat, you should start with setting up a multi-button press system. I created a basic script to detect multiple presses within X time, located here .

http://answers.unity3d.com/questions/340593/how-do-i-make-a-double-tap-system-for-dashing.html

Something to know is that the script resets to 0.5 after every key press. You may or may not want to change that depending on your requirements.

PS: Please bare with me if the script here ( not the link ) doesn't compile. I just wrote that, and am not near Unity to test compile it, but, it's so simple that any error should be fixable if even one ..... Good luck, and let me know if this does not work for you.

Comment
Add comment · 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

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

10 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

Related Questions

Yet another NullReferenceException question. 2 Answers

Destroy Turret with machine Gun 0 Answers

OnTriggerStay2D only detecting trigger collisions while moving 3 Answers

Full Performance On Melee Combat 0 Answers

Making the object collide while moving in the forward dir. (Vector3.forward) 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