- Home /
Instantiate Prefab dont work
Hey, my problem is I want to instantiate a prefab (its a laser) on an ufo which is moving up and down with the Ping Pong effect (Ufo Movement is script 1). I've created a script which should instantiate the prefab on the position of the ufo, but it wont spawn (instantiate Laser: Script 2). The Debug.Log("test"); doesnt get triggert.
Extra information: I'm controlling the Ufo with my Score, which means, when the player reaches a score of 100 the ufo will appear (with the command: ufo.SetActive(true);). I thought its usefull to let you know this. But this is (hopefully) not the problem.
Script 1:
public class MovementBoss_2 : MonoBehaviour
{
public float speed;
void start()
{
}
void Update()
{
transform.position = new Vector2 (0, Mathf.PingPong (speed * Time.time , 14-5)+5);
}
Script 2:
{
public GameObject Laser;
void Start()
{
}
void update()
{
Vector3 Position = new Vector3(transform.position.x, transform.position.y, transform.position.z);
Instantiate(Laser, Position, Quaternion.identity);
Debug.Log("test");
}
Answer by N-8-D-e-v · Sep 03, 2020 at 04:23 PM
First off, in c# we follow certain naming conventions, Pascal for methods and classes, and camel for variables. Here's a video explaining those here Unity's Monobehaviour methods (Start, Awake, Update) all follow the pascal naming convention, so
void update()
should be
void Update()
This is your issue, good luck with this!
Your answer
Follow this Question
Related Questions
Instantiate GameObject at Random time is not working 1 Answer
ParticleSystem showing in scene but not in game. 7 Answers
How to move Instantiated 2D objects by 0.5 using arrows(or mouse) 1 Answer
Unity 5 - 2d Instantiate at mouse position 1 Answer
How to move Instantiated 2D objects by 0.5 using arrows 1 Answer