shooting example part4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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