I have been using Unity for about 2 weeks now and after brief knowledgeI am trying to make an FPS game and it requires only shooting. The way i want to approach is as follows:
The camera has a raycast and has the crosshair GUI texture at the centre thus the gun does not have any bullets it only animates when the mouse is clicked.
When the raycast hits a gameobject tagged "enemy" the crosshair changes to red
And if the mouse is clicked at the same moment then i want the player to animate according to the organ that is hit . Example if it hits the head the health directly goes to zero and animation plays.
The third step is doubtful . I was thinking that when mouse is clicked then the name of the organ colliding with the ray is stored as a string this maybe can be done by keeping different name for chest, head, arms, legs etc.
Then its passed on to a Javascript associated with the enemy and it checks: if the string is "leftArm" then it plays some animation and health drops by 20% or if "rightLeg" then something else and health drops by something else.
But there is a problem that even when i am reloading the gun keeps shooting how to rectify it? Are there any other problems that i might face due to this?
Since i am new to this i have a small doubt. If i have something like this :
// i could get "leg" by the above mentioned method
if(shotOrgan = "leg"){
enemyCharactor.animation.Play("legHurt");
audio.PlayOneShot(pain scream);
health -= 20;
}
Do the animation and sound take place simultaneously or is it like first the animation occurs and then the sound plays?
Sorry for a big post..... i am very new and its my first question!