My prefub is sphere. The problem is that it doesn't move.
using UnityEngine;
public class SphereController : MonoBehaviour
{
private GameObject sphereInstantiated;
void Start()
{
sphereInstantiated = Resources.Load<GameObject>("Character");
Instantiate(sphereInstantiated, new Vector3(0, 0, 0), Quaternion.identity);
}
void Update()
{
sphereInstantiated.transform.position = Vector3.forward * 100 * Time.deltaTime;
}
}
I tried to instantiate object by public variable, nothing changed.
CodePudding user response:
Problem solved. Final code
using UnityEngine;
public class SphereController : MonoBehaviour
{
private GameObject sphere;
private GameObject sphereInstantiated;
void Start()
{
sphere = Resources.Load<GameObject>("Character");
sphereInstantiated = Instantiate(sphere, new Vector3(0, 0, 0), Quaternion.identity);
}
void Update()
{
sphereInstantiated.transform.position = Vector3.forward * 100 * Time.deltaTime;
}
}