hello gents,
I’m beginner in unity and I write a script that control a crane movement it’s work perfect, but the problem is no limitation for arrow movement.
here is the script.
public class Crane : MonoBehaviour
{
public float TurnSpeed;
public GameObject craneTop;
public GameObject Hook;
public GameObject Top1; // Arrow 1
public GameObject Top2; // Arrow 2
// Update is called once per frame
void Update()
{
if (Input.GetKey(KeyCode.D))
TurnCrane();
if (Input.GetKey(KeyCode.A))
TurnCraneLeft();
if (Input.GetKey(KeyCode.W))
UP();
if (Input.GetKey(KeyCode.S))
DOWN();
if (Input.GetKey(KeyCode.R))
UP_1();
if (Input.GetKey(KeyCode.E))
DOWN_1();
}
public void TurnCrane()
{
craneTop.transform.Rotate(Vector3.forward, TurnSpeed * Time.deltaTime);
}
public void TurnCraneLeft()
{
craneTop.transform.Rotate(Vector3.back, TurnSpeed * Time.deltaTime);
}
public void UP()
{
Top1.transform.Rotate(Vector3.left, TurnSpeed * Time.deltaTime);
}
public void DOWN()
{
Top1.transform.Rotate(Vector3.right, TurnSpeed * Time.deltaTime);
}
public void UP_1()
{
Top2.transform.Rotate(Vector3.left, TurnSpeed * Time.deltaTime);
}
public void DOWN_1()
{
Top2.transform.Rotate(Vector3.right, TurnSpeed * Time.deltaTime);
}
}
