- Home /
Simple First Person Attack Script
Quite new with Unity iOS, and I am creating a simple first person game. I have a first person prefab that moves with joysticks, and an enemy that plays an attack animation when in close proximity. I need a way to make the first person loose health when the enemies attack animation is played for at least half of the animation, when in certain proximity of the first person prefab. The animation can still fully play, but if the first person prefab starts running away before the animation is done, I do not want health to be removed since this would be un-realistic... Should be a simple script (I believe), but not to sure on how to approach it... Any suggestions or scripting help would be greatly appreciated!
Answer by Mentalist4006 · Jul 10, 2012 at 10:15 PM
In the animation window, call a function (which is in a separate script) within the attack animation. The script can use raycast to find the one being attacked as well as the distance. If the attacker is close enough, then apply damage to the other character.
Answer by zillion · Jul 11, 2012 at 05:07 AM
Great! Thank you very much for your help! Hopefully I can write a script for this, quite new to Javascript :) Will post my answer here (if I get it working) for others to see
Your answer
Follow this Question
Related Questions
Need help with simple RayCast Attack script 1 Answer
Why target frame rate either 60 or 30, how about 50? 3 Answers
Android/IOS First Person Shooter 2 Answers
IOS Gun shooting script 1 Answer
Is it possible to utilise iPad Pro's 120hz display? 1 Answer