Hello, i’m totally beginner, how can I make a cube instantiate, every time I click and when it drops to the substrate?
I’m making a balance game, for practice.

Hello, i’m totally beginner, how can I make a cube instantiate, every time I click and when it drops to the substrate?
I’m making a balance game, for practice.

It’s a good idea to start here for Unity: https://unity3d.com/learn/beginner-tutorials
Anyhow, you could create a cube prefab that you instantiate when GetMouseButtonDown(0) is true in Update.
As for falling, you could add a rigidbody to it, and see if that’s what you’re going for.
I watched those tutorials, I made it drop by click and I restricted movement, I tried to make it when I clicked to instantiate, but things went wrong
Did you also do the tutorials, and not just watch them? That’s very important/useful.
I would suggest that if you did not, that you go back and follow along the tutorials, again, and write out the code yourself, rather than just copying and pasting… it will help you remember.
As for your issues. Feel free to post your code in the thread, using code tags: Using code tags properly - Unity Engine - Unity Discussions
Maybe someone will be able to assist you further.
Here is my Click for drop code
using System.Collections;
using UnityEngine;
public class ClickB : MonoBehaviour {
public Rigidbody rb;
void Start()
{
rb.GetComponent<Rigidbody>();
}
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
rb.AddForce(-transform.up * 1.5f);
rb.useGravity = true;
GameObject varGameObject = GameObject.FindWithTag("Wood");
varGameObject.GetComponent<Movement>().enabled = false;
}
}
}
And my instantiation code
using System.Collections;
using UnityEngine;
public class Spaw : MonoBehaviour
{
public GameObject spawnees;
void Start()
{
Instantiate(spawnees, transform.position, transform.rotation);
}
void Update()
{
if (Input.GetButtonDown(0))
{
Instantiate(spawnees, transform.position, transform.rotation);
}
}
}
So, what happens with this code? What “went wrong” ?
Someone?
Sorry, I didn’t understand your previous response. What does “the others do not see” mean?
Right now, is one game object spawned and falling? But you want to be able to click again and another is instantiated and falls, too? or something else?
, It means that the others are not seen on the scene, but they are seen in hierarchy.
Yes, I want to do the same again.
Sorry for my bad English.
I see, okay… well, select them in the hierarchy, then switch to the scene view and see where they are.
Maybe you can figure out what happened to their position.
I made it, but it is now moving even when it falls down.
Edit: All right, I solved, the problem was in the left and right movement scripts,
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour {
public int speedAmt = 2;
public Rigidbody rb;
void Start()
{
rb.GetComponent<Rigidbody>();
}
void Update()
{
if (transform.position.x <= -2)
{
speedAmt = 2;
}
if (transform.position.x >= 2)
{
speedAmt = -2;
}
}
}
Code whic i add is
transform.Translate(speedAmt * Time.deltaTime, 0, 0);
if (Input.GetButtonDown("Fire1"))
{
speedAmt = 0;
}