Hello, i use this code to shooting.
But I need to bullet flew straight from the front of the SpaceShip like a picture1. How can i do it?
Thanks
`
using UnityEngine;
using System.Collections;
public class Bullets : MonoBehaviour {
public float speed;
void Start () {
speed = 20f;
}
void Update() {
Vector2 position = transform.position;
position = new Vector2(position.x, position.y + speed * Time.deltaTime);
transform.position = position;
Vector2 max = Camera.main.ViewportToWorldPoint(new Vector2(1, 1));
if (transform.position.y > max.y)
{
Destroy(gameObject);
}
}
void OnTriggerEnter2D(Collider2D col)
{
if (col.tag == "EnemyShip")
{
Destroy(gameObject);
}
}
}
`