Im really new so if any answers could be as simple as explained as possible so I can learn that would be great
Now, Ive got a character that moves forwards and backwards great, and rotates pretty good too. But if you rotate the character he does not follow the direction. I mean if you turn, it turns but if you go forward after he still goes straight, not the direction youre aiming at. Thanks!
using UnityEngine;
using System.Collections;
public class Addbuttons : MonoBehaviour {
void OnGUI()
{
//Forwards
if (GUI.RepeatButton(new Rect(65, Screen.height-125, 70, 30), "Forward") == true)
{
GameObject Player = GameObject.Find("objPlayer");
Player.transform.Translate(Vector3.forward/20 , Space.World);
}
//Backwards
if (GUI.RepeatButton(new Rect(65, Screen.height-50, 70, 30), "Backward") == true)
{
GameObject Player = GameObject.Find("objPlayer");
Player.transform.Translate(Vector3.back/20 , Space.World);
}
//Left
if (GUI.RepeatButton(new Rect(10, Screen.height-90, 70, 30), "Left") == true)
{
GameObject Player = GameObject.Find("objPlayer");
Player.transform.Rotate(0,-2,0);
}
//Right
if (GUI.RepeatButton(new Rect(120, Screen.height-90, 70, 30), "Right") == true)
{
GameObject Player = GameObject.Find("objPlayer");
Player.transform.Rotate(0,2,0);
}
}
// Update is called once per frame
void Update () {
}
}