Implemented a movement controller.

This commit is contained in:
Atlas Cove
2020-02-06 17:00:19 +00:00
parent 78ba7275ef
commit 7e657bc5d4
25 changed files with 1453 additions and 119 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 950cc6d2bbff5bc4f9439caba4f5ed96
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bullet : MonoBehaviour
{
Rigidbody2D rb;
public float damage;
public float time = 2f;
public void ApplyVel(Vector2 dir,float speed) {
rb = GetComponent<Rigidbody2D>();
rb.velocity = dir * speed;
Destroy(gameObject, time);
}
private void OnCollisionEnter2D(Collision2D c) {
Destroy(gameObject);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0d44ecfac57ea864390136ef706f6ad3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
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);
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 4c9d76b1e7bbf2d498eca3de6f5f8d08
labels:
- 2d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: