Hi, I'm making a tank that has a main cannon and a small machine gun in it. i need my spawn point for my machinegun to move like the mouse look script.
i tried adding mouse look to my spawnpoint so my spawnpoint would look the way my mouse is. and it did.
but when i shot my bullets it doesnt shoot the direction the spawnpoint is facing. i want to shoot left by turning my spawnpoint that direction. but my bullets keep shooting forward and wont shoot any other direction.
here is my script im using to shoot bullets. i used the tornado twins script to make it.
static var InVehicle = false;
var speed = 3.0;
var rotateSpeed = 3.0;
var bullitPrefab : Transform;
static var InGun = false;
var bulletPrefab : Transform;
function Update ()
{
if(InVehicle){
var controller : CharacterController = GetComponent(CharacterController);
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);
if(Input.GetButtonDown("Jump"))
{
var bullit = Instantiate(bullitPrefab, GameObject.Find("spawnpoint").transform.position,
transform.rotation);
bullit.tag = "wormProjectile";
bullit.rigidbody.AddForce(transform.forward * 10000);
}
}
if(InGun)
{
if(Input.GetButton("Fire1"))
{
var bullet = Instantiate(bulletPrefab, GameObject.Find("gunspawnpoint").transform.position,
transform.rotation);
bullet.tag = "wormProjectile";
bullet.rigidbody.AddForce(transform.forward * 5000);
}
}
}
could you please tell me what i need to do or a part of a script i might need to make the bullit shoot in the direction the spawnPoint is facing?
Thanks, anyone who wants to help!!!