Fireball not moving with speed.

var bulletprefab:Transform;

function Update ()

{

if(Input.GetButtonDown(“Fire2”))
{
Instantiate(bulletprefab,GameObject.Find(“SpawnpointA”).transform.position, Quaternion.identity);
bulletprefab.rigidbody.AddForce(transform.forward * 5000);

}

}

This is the script I have. Im trying to make a fireball shoot from a worm, but it needs force. When I press the button for the fireball it has no force, it just sits there, Help? How do I change this to give my rigidbody force?

5000 maybe the reason, have you tried a smaller number? could be that 5000 is out of bounds

also have you had a look at this thread?

I started with a smaller number at first. And that’s hard to understand

my suggestion is to break down the math to invidual componants and understand what each one does, not be concerned with understanding it all in one gulp for now. programming and math are similar in the fact they are much easier to follow when broken down piece by piece or line by line.

Your code attempts to add force to the source prefab and not the newly created object.

You don’t store the value (GameObject) returned by Instantiate and you need that result to reference the newly created bullet for subsequent calls.

var newBullet : GameObject = Instantiate(bulletprefab,GameObject.Find("Spawnpoi ntA").transform.position, Quaternion.identity);
newBullet.rigidbody.AddForce(transform.forward * 5000);

var before newbullet doesn’t work. it does work without it.

var bulletprefab:Transform;

function Update ()

{

if(Input.GetButtonDown(“Fire2”));
{
bulletprefab : GameObject = Instantiate(bulletprefab,GameObject.Find(“SpawnpointA”).transform.position, Quaternion.identity);
bulletprefab.rigidbody.AddForce(transform.forward * 5000);

}

}

Now it says: Expecting }, found =
It still says it when I get rid of the equal sign.

it also says unexpected token: newbullet. after I relized my mistake and new bullet will work instead of bulletprefab

This is a more complete/correct solution for what you are trying to do.

var bulletPrefab : GameObject;
var spawnPoint : Transform;

function Start()
{
  spawnPoint = GameObject.Find("SpawnpointA").transform;
}

function Update()
{
   if(Input.GetButtonDown("Fire2"))
   {
     var bullet : GameObject = Instantiate(bulletPrefab, spawnPoint.position, Quaternion.Identity);
     bullet.rigidbody.AddForce(transform.forward * 50);
   }
}

MissingFieldException: UnityEngine.Transorm.GameObject
I couldn’t even begin to comprehend this.