- Home /
Transform.translate bullets problem
I've been trying to make the player shoot bullets. And I cant seem to figure out how to get the direction then move to change.
I accessed the player script to see where the player is facing to try to tell it how to move.
I use ifs to change the variable "speed" to be positive or negative depending on where the player is facing. Then I use the variable speed to translate on the xaxis by time.deltatime.
There is no issue with the reference with the script that is telling where the player is facing, just with changing the variable to positive or negative.
Here is the script attached to the bullet
 public class BulletForce : MonoBehaviour {
 
     public GameObject player;
     private PlayerMovement playerConservator;
     public bool faceRight;
     public float speed = 10;
 
 
 
     // Use this for initialization
     void Start () 
     {
         player = GameObject.Find ("PlayerConservative");
         playerConservator = player.GetComponent<PlayerMovement> ();
         faceRight = playerConservator.referenceFacingRight;
 
         if(playerConservator.referenceFacingRight = false && speed > 0)
         {
             speed = -speed;
         }
         else if(playerConservator.referenceFacingRight = true && speed < 0)
         {
             speed = -speed;
         }
 
 
     }
     
     // Update is called once per frame
     void Update () 
     {
         transform.Translate(new Vector2(speed, 0 ) * Time.deltaTime);
     }
 
 }
 
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                