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!

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

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.

example? im fairly new to unity

Thanks, I havent thought of that... Thanks for the tip. I will be back with even more questions. beware.

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 Answer

1

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.