what all would be involved in terms of having to script for a character say, swinging a sword and hitting an enemny
would i have to create a character model, animate the swing, create a sword model, attach it, and make its collider a trigger to lower enemy hp and what else?
is there anything else involved and what references online would be closest related to this situation in terms of coding
Those would certainly sound like good steps to get you there. As far as references while not directly the same, the 1st person tutorial has some dealings with animation, projectiles, etc. that may prove to give some ideas on how to accomplish some of the tasks you are looking at.
im going to have to do this to soon, so i would also like to feel special and get some good info from here too
i was thiking i would have an invisible game object floating in front of my character at the distance i think his attack should be effective, and when he does his attack animation the invisible game object would be “active” a boolean to decide if he is swiging his sword, if “acive” is true then it would check to see if it the invisible object is hitting the enemy
and then do damge and all that stuff like that
thats just how im doing it, has anyone found some better ways??
also im having problems with getting my charecter to hold the sword, the only reason i did the melee attack with the invisible objet is becuase the sword is part of my char-mesh, when i switch weopons i switch the entire char mesh and sometimes it creates a noticable lag
how do you guys have your char holding the sword??
If your character is in FPS then I would create an animation sequence of a hand/arm holding a weapon in my fav 3d app (Maya in my case). The first lot of frames would be the holding state, the next seq of frames would be attack 1, then the next attack 2, etc.
Then I would attach that model/animation to the the FPS control, alot like you would with the gun in the FPS tutorial. Then I would assign a box collider to encompass the sword/axe/whatever model that is held in the 3d hand which is part of your animation set. Then I would assign various keys to access different parts of the animation sequence using the APIs found here: http://unity3d.com/Documentation/ScriptReference/30_search.html?q=animation
So when the player presses a key then that animation is played and all the collision detection is handled by the box collider on the sword.
So your enemy would have an oncollision event and that is where you take off the HPs etc. This is only called when the weapon collides with the enemies rigidbody/collider etc.
Cant help sorry. I got heaps of reference together for a medieval fantasy theme then School kicked in with a WW1 theme and I got hired for a scifi project so never got far down this track…good luck thou
AC