Unity cube move with UI buttons full and easy script.Hey,Guys welcome back to unity tips pro site.In this post we discus about How to move cube with UI buttons.This is very Easy and fast trick.I teach you step by step How to move cube with UI buttons.So lets get started...

player move with ui buttons.cube move with UI buttons

Also check This post

Unity Amazing free assets              Windridge City
Top 3 game made with unity          Made with unity
Unity 3d lights on/off with UI       Lights on/off


Cube move with UI button steps

  1. First we need 3d plan and one cube.
  2. Add rigid-body component to cube
  3. Add this script to cube
/////////////////////////////////////////////////////////............/////////////////////////////////////////////////////////////
using UnityEngine;
using System.Collections;

public class CubeMove : MonoBehaviour {

    public float speed;

    private Rigidbody rb;

    void Start ()
    {
        rb = GetComponent<Rigidbody>();
    }

    void FixedUpdate ()
    {
       // float moveHorizontal = Input.GetAxis ("Horizontal");
       // float moveVertical = Input.GetAxis ("Vertical");

        
       // Vector3 movement = new Vector3 (5f, 0.0f, 2f);
        
    }

public void Right() 
{
Vector3 movement = new Vector3 (10f, 0.0f, 0.0f);
rb.AddForce (movement * speed);
}

public void Left() 
{
Vector3 movement = new Vector3 (-10f, 0.0f, 0.0f);
rb.AddForce (movement * speed);
}

public void Farward() 
{
Vector3 movement = new Vector3 (0.0f, 0.0f, 10f);
rb.AddForce (movement * speed);
}

public void Back() 
{
Vector3 movement = new Vector3 (0.0f, 0.0f, -10f);
rb.AddForce (movement * speed);
}

}

/////////////////////////////////////////////////////////............/////////////////////////////////////////////////////////////

4.Add four UI buttons to move cube like forward,back,left and right move.like this image

unity move objects with ui buttons

 . 5.Add public functions to UI buttons like "public void Right()" function to right move button and same other functions.
  6.Test and play your cube.