You are on page 1of 1

using System.

Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameControl : MonoBehaviour


{
Rigidbody rb;
private float movementX;
private float movementY;

public float speed;

// Start is called before the first frame update


void Start()
{
rb = GetComponent<Rigidbody>();
}

// Update is called once per frame


void Update()
{
movementX = Input.GetAxis("Horizontal");
movementY = Input.GetAxis("Vertical");
rb.AddForce(movementX * speed, 0, movementY * speed);

}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Enemy")
Destroy(gameObject);
if (collision.gameObject.tag == "Plane")
rb.AddForce(Vector3.up * 350);
}

You might also like