• 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 /
This question was closed Apr 30, 2013 at 09:19 AM by Fattie for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by BLOODLORD · Apr 30, 2013 at 08:00 AM · gameobjectphysicsraycastcollider

Melee-like function?

Hi! I'm making an Island survival game. I want the character to punch trees, how do I do that? (no, I'm not making minecraft) Anybody with a snippet of useful code is deeply appreciated!

Comment
Add comment · Show 5
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 Fattie · Apr 30, 2013 at 09:19 AM 0
Share

give your character a punch animation. when user presses P make the animation run. search for 10000s article on this here

avatar image BLOODLORD · Apr 30, 2013 at 10:18 AM 0
Share

yea, but i want it to be in a limited range, so when the character is close to the tree so it triggers damage. but I don't know how to add limited attack range function. also I would like to know how to change animation on player positon, like when the player is near a tree, he punches and the fist comes to a dead stop, else, swing and a miss.

avatar image BLOODLORD · Apr 30, 2013 at 10:38 AM 0
Share

example? im fairly new to unity

avatar image BLOODLORD · Apr 30, 2013 at 10:50 AM 0
Share

Thanks, I havent thought of that...

Thanks for the tip. I will be back with even more questions. beware.

avatar image fafase · Apr 30, 2013 at 11:49 AM 0
Share

At the end of this article http://unitygems.com/basic-ai-character/#Sight you have a way to create a melee attack based on animation event.

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by Fornoreason1000 · Apr 30, 2013 at 10:24 AM

use ray casting and distances.

you could also use collision, when collision is detected stop the animation in its tracks. Anination class will have something that will do the trick but as fattie said there are hundred of these questions. finding the question and using information people already answered will save you a lot of time waiting here

make sure you research into them first, and make sure they aren't already answered, also why are you posting this as answer. the Devs on here tend to get annoyed with things like this.

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

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

16 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Detecting other Objects when placing Object 1 Answer

raycasts only working with IsTrigger colliders? 1 Answer

how to move an object clone to mouse position, i dont understand ? 1 Answer

Camera raycast and rotated collider 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