technix/Assets/script/movement/PlayerController.cs

39 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour {
Vector3 direction;
public float speed;
#if tmp
public GameObject bullet;
#endif
AudioSource aus;
// Start is called before the first frame update
void Start() {
aus = GetComponent<AudioSource>();
}
// Update is called once per frame
void Update() {
//direction = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);
gameObject.transform.position += Vector3.Normalize(new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0))*0.25f;
/*if(Input.GetButtonDown("Fire1")) {
Vector3 offset = transform.position + new Vector3(lastDirection.x+0.1f, lastDirection.y+0.1f, 0f);
aus.Play();
GameObject.Instantiate(bullet, offset, Quaternion.identity);
}*/
}
/*private void FixedUpdate() {
gameObject.transform.position += Vector3.Normalize(direction)*0.1f;
}*/
public void Move(InputValue v) {
var m = v.Get<Vector2>();
gameObject.transform.position = new Vector3(m.x, m.y, 0f);
}
}