Skip to content

Instantly share code, notes, and snippets.

@daleth90

daleth90/Hero.cs Secret

Created Aug 11, 2017
Embed
What would you like to do?
shooting example part4
using System;
using UnityEngine;
using Zenject;
public class Hero : MonoBehaviour {
[Serializable]
public class Setting {
public float speed = 5f;
}
[SerializeField]
private Transform muzzle;
private Setting setting;
[Inject]
private void Init( Setting setting ) {
this.setting = setting;
}
public void Move( Vector2 input ) {
transform.Translate( setting.speed * Time.deltaTime * input, 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