using UnityEngine;
using System.Collections;
[RequireComponent (typeof (BulletCollision))]
public class Bullet : MonoBehaviour{
public float bulletSpeed = 9;
float gravity = 0;
Vector3 velocity;
Controller2D controller;
BulletCollision bulletController;
int flipNumber = 1;
void Start () {
bulletController = GetComponent<BulletCollision> ();
controller = GetComponent<Controller2D> ();
}
void Update () {
/*
if (controller.collisions.faceDir != 1) {
flipNumber = -1;
} else {
flipNumber = 1;
}*/
velocity.x = bulletSpeed * controller.collisions.faceDir;
velocity.y += gravity * Time.deltaTime;
bulletController.Move (velocity * Time.deltaTime);
}
}
I need to make the bullet coming from the player to fire in the correct direction. My thought was that I need a way to reference the collisions.faceDir variable form the Collisions2d script without having to put it onto my bullet prefab. If anyone could help me with how to do this or with some other solution that would be great!