Skip to content

Instantly share code, notes, and snippets.

@daleth90

daleth90/Hero.cs Secret

Created Jul 26, 2017
Embed
What would you like to do?
shooting example
using UnityEngine;
public class Hero : MonoBehaviour {
[SerializeField]
private Transform muzzle;
[SerializeField]
private float speed = 5f;
public void Move( Vector2 input ) {
transform.Translate( speed * input * Time.deltaTime, Space.World );
if ( input != Vector2.zero ) {
float degree = Mathf.Atan2( input.y, input.x ) * Mathf.Rad2Deg;
transform.eulerAngles = new Vector3( 0f, 0f, degree - 90f );
}
}
public Transform GetMuzzle() {
return muzzle;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment