|
Can someone explain how this is done please? I'm trying to do melee combat for my game and I have animated my sword to swing. I've never used this before and have no idea how to implement it and the api isn't very helpful. I have added an empty object and a box collider around the blade of the sword. I've added it as a child of the sword and have ticked Is Trigger. This is the script I have so far. But it doesn't seem to be doing anything. This is the script for the health and AdjustCurrentHealth The health script is attached to my enemy and the melee attached the the empty game object with the box collider.
(comments are locked)
|
|
OnTrigger functions require a rigid body attached as stated here: http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnTriggerEnter.html. usually put it on the moving element. just set the rigid body to is kinematic so it isnt affected by any forces acted upon it.
(comments are locked)
|

Try starting with a smaller test: comment out AdjustCurrentHealth and try to get only the Debug to run. Things to check: has the enemy tag been set to "Enemy"? Try selecting the arm in sceneView to be sure it's moving with you. In general, the "moving triggerBox" idea does work.