mirror of
https://github.com/ConjureETS/OuijaMTLGJ2016.git
synced 2026-03-24 10:11:07 +00:00
32 lines
904 B
C#
32 lines
904 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
public class PlayerBehaviour : MonoBehaviour {
|
|
|
|
public int playerNumber;
|
|
public float speed = 10;
|
|
public GameObject anchor;
|
|
public float maxRangeFromAnchor = 3;
|
|
|
|
// Use this for initialization
|
|
void Start () {
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update () {
|
|
string horizAxisString = "Horizontal"+(playerNumber==1?"":playerNumber.ToString());
|
|
string vertAxisString = "Vertical"+(playerNumber==1?"":playerNumber.ToString());
|
|
|
|
Vector3 movement = new Vector3 (Input.GetAxis(horizAxisString), Input.GetAxis(vertAxisString), 0) * speed;
|
|
|
|
if (movement.magnitude > speed)
|
|
movement = movement.normalized * speed;
|
|
|
|
//if((transform.position + movement - anchor.transform.position).magnitude >= maxRangeFromAnchor)
|
|
// movement -= anchor.transform.position - transform.position
|
|
|
|
transform.position += movement * Time.deltaTime;
|
|
}
|
|
}
|