Problem with Instantiate (maybe)

Hello Community,
i’ve a problem with my code.
In this code, a canon will shoot bullets.

var LookAtTarget : Transform;
var damping : float = 6.0;
var bullet_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 * damping);
		var secounds : int = Time.time;
		var oddeven = (secounds % 2);
		if (oddeven){

function shoot(){
	if(secounds != savedTime){
		var bullet = Instantiate(bullet_Prefab, transform.Find("SpawnPoint").transform.position, Quaternion.indentity);
		bullet.rigidbody.AddForce(transform.forward * 1000);
		savedTime = secounds;

Million Errors occur ,when i start the game:

NullReferenceException: Object reference not set to an instance of an object
TurnetController.shoot () (at Assets/Scripts/TurnetController.js:23)
TurnetController.Update () (at Assets/Scripts/TurnetController.js:16)

I hope you can help me and sorry for my bad English.

Thank you in advance!


This line looks incorrect.

you have transform in the expression twice.

Perform your Find(“SpawnPoint”) before your instantiate call (and note that Find is expensive) and pass the Find to a variable, say spawnTransform, then use spawnTransform.transform.position.

I think that would work.