Skip to content

Instantly share code, notes, and snippets.

@istar0me
Created October 30, 2018 06:58
Show Gist options
  • Save istar0me/50934b7f9f102f1740c6e362892c9fc4 to your computer and use it in GitHub Desktop.
Save istar0me/50934b7f9f102f1740c6e362892c9fc4 to your computer and use it in GitHub Desktop.
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