I currently have a working (but extremely simple) Melee Combat system. All works ( for the most part ) as far as collision goes. The problem however, is adding realistic impact so that the player has time to hit the enemy several times before the enemy can reach distance for attacking.
Things to know:
-Both Objects are Ragdolls .
The problem:
-Sometimes, depending on the type of attack, the ninjas 'sword' does not collide with the enemy. I know this has everything to do with the animations coords. But how do I ensure I always get a hit, as well as a nice knockback factor. On about three of my animations, the characters alignment causes the collider to always be in contact with the targeted collider, and that's not what I want :\
Here is a photo of the colliders seperated:
![alt text][1]
And here is them colliding:
![alt text][2]
[1]: http://i45.tinypic.com/sfi0d2.jpg
[2]: http://i48.tinypic.com/2s9qfd4.jpg
And here are my scripts:
//Sword Collision
function OnTriggerEnter ( collision : Collider ){
if ( !Controller.Player.Attacking || collision.tag != "Zombie")
{
return;
}
//Debug.LogWarning("Collided with" + collision.collider.tag);
if ( collision.tag == "Zombie" )
{
Controller.Player.Kombat.HitCount += 1 ;
Controller.Player.Kombat.HitCountCooler = Controller.Player.Kombat.HitCountCoolerMax ;
if ( Controller.Player.Kombat.HitCount > 4 ){
Instantiate( Resources.Load ( "Detonator-Crazysparks" ), transform.position, Quaternion.identity ) ;
Controller.Player.Kombat.HitCount = 0 ;
}
Debug.LogWarning ( "Collision33?" );
EnemyMotor = collision.GetComponent ( ZombieMotor ) ;
EnemyMotor.SendMessage ( "DamageFactor", 300 ) ;
collision.GetComponent( AddForce ).addForce ( -Vector3.forward, 10 );
Instantiate( Resources.Load ( "Assets/Standard Assets/Detonator/Prefab Examples/Detonator-Crazysparks.prefab" ), transform.position, Quaternion.identity ) ;
}
}
//Zombie Damage Factor
function DamageFactor ( damage : float )
{
if ( ZombieIntelligence.Zombie.Kombat.Health < 0 ){
Kill ( ) ;
}else{
var myForce : AddForce ;
myForce = GetComponent ( AddForce ) ;
myForce.addImpact ( Vector3.forward, 10 ) ;
}
ZombieIntelligence.Zombie.Kombat.Health -= damage * ( ZombieIntelligence.Zombie.Kombat.Defense / 100 );
}
Any help is greatly apreaciated! Thanks in Advance!
~Montray
↧