if(seconds=savedTime)

I put
if(seconds=savedTime)
{

var bullet = Instantiate(Prefab, gameObject.Find(“SpawnpointB”).transform.position, Quaternion.identity);
bullet.rigidbody.AddForce(transform.forward * 1000);

savedTime = seconds;
}

There is more code n stuff, but I have an error that says it was expecting a ) not and =
I messed around and found the issue lies in
if(seconds=savedTime)
How do I fix this?
Thanks.

bump.

Try : if(seconds >=savedTime) ,if(seconds <=savedTime) or if(seconds==savedTime).

“=” is assignment. “==” is comparison. Note that if you’re running that in Update and the values are based on time there is a very good change the 2 will never equal each other exactly.

= does the same thing it did before, which is spit abunch of bullets.
<= makes it so it doesn’t shoot anything
== makes it so it doesn’t shoot anything.
=/
hmm.

Use the first, only need is use Time.time to control the bullets shooting per time.

if(seconds > savedTime * Time.time)

or :

function Fire () {    if (bulletsLeft == 0)
        return;
    
    // If there is more than one bullet between the last and this frame
    // Reset the nextFireTime
    if (Time.time - fireRate > nextFireTime)
        nextFireTime = Time.time - Time.deltaTime;
    
    // Keep firing until we used up the fire time
    while( nextFireTime < Time.time  bulletsLeft != 0) {
        FireOneShot();
        nextFireTime += fireRate;
    }
}

its rlly difficult to incorporate that into what I already have

var LookAtTarget:Transform;
var damp = 6;
var Prefab:Transform;
var savedTime = 0;

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*Time.time)
{

var bullet = Instantiate(Prefab, gameObject.Find(“SpawnpointC”).transform.position, Quaternion.identity);
bullet.rigidbody.AddForce(transform.forward * 1000);

savedTime = seconds;
}
}
is there an all around easier way to do this?
I know there is

function Update (){
    if (Input.GetKey(KeyCode.F))
    {
        Fire ();
    }
}


function Fire () {
    if (bulletsLeft == 0)
    return;
    // If there is more than one bullet between the last and this frame
    // Reset the nextFireTime
    
    if (Time.time - fireRate > nextFireTime)
    nextFireTime = Time.time - Time.deltaTime;
    // Keep firing until we used up the fire time
    while( nextFireTime < Time.time  bulletsLeft != 0)
    {
        FireOneShot();
        
        nextFireTime += fireRate;
        
    }
}


function FireOneShot()
{
    var bullet = Instantiate(Prefab, gameObject.Find("SpawnpointC").transform.position, Quaternion.identity);
    bullet.rigidbody.AddForce(transform.forward * 1000);
}