Making projectile move, go forward

IM trying to get my projectile to move forward and ive tried these methods, it just drops to the ground.

bullet.rigidbody.AddForce(transform.position * 1000);

bullet.velocity = transform.TransformDirection( Vector3( 0, 0, speed) );

transform.position += Time.deltaTime * speed * transform.forward;

Thanks in advance for your help.

PS : Im using Unity iPhone, and Im using JavaScript

EDIT : I got the first one to work :)

Drops to the ground? You mean like gravity is making it drop? You can turn off gravity by:

Bullet.rigidbody.useGravity = false;

Are you starting your object at a position high enough so it has some height to fall before hitting the ground?

Generally this is what you do to move objects forward, you may have other factors like gravity affecting your object if it has a rigidbody attached.


transform.Translate(Vector3.forward * Time.deltaTime * speed);

This could be used:

var Bullet : Transform; // place bulletPrefab here.

function Update ()





   Bullet.rigidbody.AddForce(transform.forward * 1000); 

// your bullet needs a rigidbody attached. It is as simple as: 

Bullet.rigidbody.AddForce(transform.forward * 1000); 

// This adds force to the variable, bullet.



I'd use the script from the FPS tutorial to spawn projectiles, and if you don't want player input i'd comment out the if statement in the playerweapons script and use that + the rocketlauncher/machinegun sripts.