I want to add to my Custom Level Editor a special function : whenever user holds a Shift key (doesn’t really matter left or right) he can more accuratly move objects (0.1 per pressing button vs 1). However, this function is not working for me… Maybe you can add your own solution and help me…
if (Input.GetKey(KeyCode.D))
{
foreach(GameObject t in selection)
{
t.transform.position += new Vector3(1, 0, 0);
}
}
else if (Input.GetKey(KeyCode.W))
{
foreach (GameObject t in selection)
{
t.transform.position += new Vector3(0, 1, 0);
}
}
else if (Input.GetKey(KeyCode.A))
{
foreach (GameObject t in selection)
{
t.transform.position += new Vector3(-1, 0, 0);
}
}
else if (Input.GetKey(KeyCode.S))
{
foreach (GameObject t in selection)
{
t.transform.position += new Vector3(0, -1, 0);
}
}
else if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift))
{
if (Input.GetKey(KeyCode.D))
{
foreach (GameObject t in selection)
{
t.transform.position += new Vector3(0.1f, 0, 0);
}
}
else if (Input.GetKey(KeyCode.W))
{
foreach (GameObject t in selection)
{
t.transform.position += new Vector3(0, 0.1f, 0);
}
}
else if (Input.GetKey(KeyCode.A))
{
foreach (GameObject t in selection)
{
t.transform.position += new Vector3(-0.1f, 0, 0);
}
}
else if (Input.GetKey(KeyCode.S))
{
foreach (GameObject t in selection)
{
t.transform.position += new Vector3(0, -0.1f, 0);
}
}
}