About Arrow :-
- Create Empty Game Object.. Rename it like 'Arrow'.
- Select 'Arrow'. Add Component ( Sprite Renderer ) to Inspector.
- Import 'Arrow.png' to Project. Select arrow.png and change Texture Type to Sprite (2D and UI)
- Change Pivot to Bottom Left (According to my Sprite). You can change your pivot according to your Sprite (image). you should keep your pivot point to arrow last end.
- To arrange custom pivot point. You should click sprite editor and change point manually as like picture below.
Code :-
using UnityEngine;
using System.Collections;
public class test : MonoBehaviour {
void Update () {
var mousePos = Input.mousePosition;
mousePos.z = 10.0f; //The distance from the camera to the player object
Vector3 lookPos = Camera.main.ScreenToWorldPoint(mousePos);
lookPos = lookPos - transform.position;
float angle = Mathf.Atan2(lookPos.y, lookPos.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
Debug.Log ("== "+Input.GetAxis("Mouse X"));
}
}
You should change your pivot point using sprite editor.
No comments:
Post a Comment