Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Move : MonoBehaviour {
- float speed = 7f;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- //Basic Movement
- if (Input.GetKey(KeyCode.W))
- {
- // Make stuff work here.
- transform.Translate(0f, speed * Time.deltaTime,0f); //x,y,z
- }
- if (Input.GetKey(KeyCode.S))
- {
- // Make stuff work here.
- transform.Translate(0f, -speed * Time.deltaTime,0f); //x,y,z
- }
- if (Input.GetKey(KeyCode.A))
- {
- // Make stuff work here.
- transform.Translate(-speed * Time.deltaTime, 0f,0f); //x,y,z
- }
- if (Input.GetKey(KeyCode.D))
- {
- // Make stuff work here.
- transform.Translate(speed * Time.deltaTime, 0f,0f); //x,y,z
- }
- //8 Directional Movement Fix
- if ((Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.D)) ||
- (Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.A)) ||
- (Input.GetKey(KeyCode.S) && Input.GetKey(KeyCode.A)) ||
- (Input.GetKey(KeyCode.S) && Input.GetKey(KeyCode.D)))
- {
- speed = 2.5f;
- }
- else
- {
- speed = 5f;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement