I just started coding in C# and I want to try to make a board game that is in a checkerboard pattern. I made a row on the bottom of the board to change the location of the object. I want to change my Objects Z transform to another’s Z’s Transform without touching the Y and X. Plz Help!
Here is my code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour {
public Transform MySelf;
public Transform ZY0;
public Transform Z1;
public Transform Z2;
public Transform Z3;
public float YMove;
public float ZMove;
void Start (){
}
void Update()
{
if (Input.GetKeyDown (“d”)) {
if (ZMove == 1)
{
MySelf.position = Z1.position;
}
if (ZMove == 2)
{
MySelf.position = Z2.position;
}
if (ZMove == 3)
{
MySelf.position = Z3.position;
}
}
}
}