i typed this code but bolts are still not firing

using UnityEngine;
using System.Collections;

[System.Serializable]
public class Boundary
{
public float xMin, xMax, zMin, zMax;
}
public class PlayerController : MonoBehaviour
{
private Rigidbody rb;

public float speed;
public float tilt;
public Boundary boundary;

public GameObject shot;
public Transform shotSpawn;
public float fireRate;

private float nextFire;

void Update ()
{
	if (Input.GetButton("Fire1") && Time.time > nextFire)
	{  
		nextFire = Time.time + fireRate;
		//    GameObject clone =
		Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
	}
}
void Start (){
	rb = GetComponent<Rigidbody> ();
}
void FixedUpdate ()
{
	float moveHorizontal = Input.GetAxis ("Horizontal");
	float moveVertical = Input.GetAxis ("Vertical");
	Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
	rb.velocity = movement * speed;

	rb.position = new Vector3
		(
			Mathf.Clamp (rb.position.x, boundary.xMin, boundary.xMax),
			0.0f,
			Mathf.Clamp (rb.position.z, boundary.zMin, boundary.zMax)
		);
	rb.rotation = Quaternion.Euler (0.0f, 0.0f, rb.velocity.x * -tilt);
}

}

Hi @Samsood27,

I had the same problem but was able to fix it with a small change to the “Initiate” function.

On line 18 of your code, change the “shotSpawn.position, shotSpawn.rotation” to “shotSpawn.transform”.

The code will then look like this:

void Update ()

{

 if (Input.GetButton("Fire1") && Time.time > nextFire)
 {  
     nextFire = Time.time + fireRate;
     Instantiate(shot, shotSpawn.transform);
 }

}