If I am standing right in front of him he will hit me then if I back up a little he will start to miss me. After a few more feet back he will start hitting me again. I think I know the problem but not sure how to fix it. this is the code I have and all the info I think you will need to help me.
On my Bullit prefab I have the following set of var’s
Mass: 0.1
Drag: 0
Angular Drag: 0.05
Use Gravity: True
Is Kinematic: False
Interpol: None
Collision Detection : Discrete
Constraints: None
This is the code on my AI
var LookAtTarget : Transform;
var damp = 6.0;
var bullitPrefab : Transform;
var savedTime = 0;
function Update ()
{
if(LookAtTarget)
{ // Finds the dif between the two Player position Turret Pos
var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position);
// rotation of the turret turret rotation, var, time that passes between frames
transform.rotation = Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime *
damp);
var seconds : int = Time.time;
var oddeven = (seconds % 2);
if(oddeven)
{
Shoot(seconds);
}
}
}
function Shoot(seconds)
{
if(seconds != savedTime)
{
var bullit = Instantiate(bulltPrefab, transform.Find("SpawnPoint").transform.position,
Quaternion.identity);
bullit.rigidbody.AddForce(transform.forward *1000);
savedTime = seconds;
}
}
And This is my code on my buillit prefab
function OnCollisionEnter(hit : Collision)
{
if(hit.gameObject.tag == "Player")
{
HC.LIVES -=1;
Destroy(gameObject);
}
if(hit.gameObject.tag == "turret")
{
Destroy(gameObject);
}
}