There are questions like this but I couldn't find any answers in C#, so here's my question: I want to rotate an object (in Unity 5) in the direction it's facing. I currently have this code to rotate my player.
using UnityEngine;
using System.Collections;
public class Movement : MonoBehaviour
{
private bool isLeft = false;
void Update()
{
if (Input.GetMouseButtonDown(0))
{
if (isLeft == false)
{
transform.rotation = Quaternion.Euler(90, 45,0);
isLeft = true;
Debug.Log("Turned Right");
}
else
{
transform.rotation = Quaternion.Euler(90, -45, 0);
Debug.Log("Turned Left");
isLeft = false;
}
}
}
While your question and description are a bit ambiguous, it seems that you want to move the arrow, in the direction it's facing, correct?
Make sure that the arrow in the game object, is pointing forwards. You can see what forward is, by selecting the game object in the scene. Forward will be the blue arrow.
Now in code, to move it in this direction, you can move it in many different ways. Apply force/Translate/Set position. I recommend you try them out, to see what looks and feels the best. To simply change its position:
transform.position += transform.forward * Time.deltaTime * movementSpeed;
Where movement speed is a float that describes how fast it should move. Time.deltaTime is necessary if you put this code in Update().