S
S
Skayl562020-06-17 11:03:10
Unity
Skayl56, 2020-06-17 11:03:10

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

1 answer(s)
F
freeExec, 2020-06-17
@freeExec

And what is it SpawnPoint, I only see it spawnPoint?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question