Well as I am making a First Person Shooting game, however the bullet shooting from the enemy seems to spray shoot upwards and I can't do anything about it at all as I don't know how Unity works, so here below is the script:
function Update ()
{
if(LookAtTarget)
{
var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position);
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(bullitPrefab ,transform.Find("Spawn2").transform.position ,
Quaternion.identity);
bullit.gameObject.tag = "enemyprojectile";
bullit.rigidbody.AddForce(transform.forward * 1000);
savedTime=seconds;
}
}
↧