Answer the question
In order to leave comments, you need to log in
How to solve error in unity in script?
Assets/SpawnPoint.cs(11,39): error CS0120: An object reference is required to access non-static member `UnityEngine.Component.transform'
My script
using UnityEngine;
public class SpawnPoint : MonoBehavior {
public GameObject spawnPoint;
public GameObject objToSpawn;
void Update () {
if (Input.GetKeyDown(KeyCode.F))
{
Instantiate(objToSpawn, SpawnPoint.transform.position, Quaternion.identity);
}
}
}
Spaces are fine
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question