BananaMovement.cs 1.25 KiB
using UnityEngine;
using System.Collections;
public class BananaMovement : MonoBehaviour {
float maxSpeed = 5f;
int BulletHealth = 1;
// Update is called once per frame
void Update() {
//move the bullet straight according to the direction its facing
if (EnemyAI.LookRight == true) {
float rotation = 360 * Time.deltaTime;
float curRotation = transform.localRotation.eulerAngles.z;
transform.localRotation = Quaternion.Euler(new Vector3(0, 0, curRotation + -rotation));
Vector3 position = transform.position;
Vector3 movement = new Vector3(maxSpeed * Time.deltaTime, 0, 0);
position += movement;
transform.position = position;
}
else {
float rotation = 360 * Time.deltaTime;
float curRotation = transform.localRotation.eulerAngles.z;
transform.localRotation = Quaternion.Euler(new Vector3(0, 0, curRotation + rotation));
Vector3 position = transform.position;
Vector3 movement = new Vector3(-maxSpeed * Time.deltaTime, 0, 0);
position += movement;
transform.position = position;
}
}
void OnTriggerEnter2D() {
Destroy(gameObject);
}
}