Created
October 30, 2018 06:58
-
-
Save istar0me/50934b7f9f102f1740c6e362892c9fc4 to your computer and use it in GitHub Desktop.
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.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Move : MonoBehaviour | |
{ | |
public GameObject myMissile; | |
// Use this for initialization | |
void Start() | |
{ | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
if (transform.position.x > -11) | |
{ | |
if (Input.GetKey(KeyCode.LeftArrow)) | |
{ | |
Vector2 v = new Vector2(Time.deltaTime * -8, 0); | |
transform.Translate(v); | |
} | |
} | |
if (transform.position.x < 11) | |
{ | |
if (Input.GetKey(KeyCode.RightArrow)) | |
{ | |
Vector2 v = new Vector2(Time.deltaTime * 8, 0); | |
transform.Translate(v); | |
} | |
} | |
if (Input.GetKeyDown(KeyCode.Space)) { | |
Vector2 v = new Vector2(transform.position.x, 0.5f); | |
Instantiate(myMissile, v, Quaternion.identity); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment