script with an error.

so I was making this script for the FPS I am making and I wanted to know what was going wrong because I got this error:
Assets/gun.cs(24,46): error CS1061: ‘Transform’ does not contain a definition for ‘postion’ and no accessible extension method ‘postion’ accepting a first argument of type ‘Transform’ could be found (are you missing a using directive or an assembly reference?)

here is the code:

using UnityEngine;

public class gun : MonoBehaviour
{
public float damage = 10f;
public float range = 100f;

public Camera fpscam;

// Update is called once per frame
void Update()
{

if (Input.GetButtonDown(“Fire1”))
{
Shoot();
}

}

void Shoot ()
{
RaycastHit hit;
if (Physics.Raycast(fpscam.transform.postion, fpscam.transform.forward, out hit, range))
{
Debug.Log(hit.transform.name);
}
}
}

my goal is to make a raycast gun script

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: Using code tags properly

How to understand compiler and other errors and even fix them yourself:

postion is not the same as position

In programming 100% of EVERYTHING must be spelled, capitalized, punctuated and spaced PERFECTLY.

2 Likes

Check your spelling

1 Like

oh I see, its position not postion thanks