Why does the rigidbody2D addforce work when using transform.up perfectly but using transform.right doesn’t work correctly. It seems to just transform the players position.
public Transform fireDirection;
public float speed = 1f;
Transform collisionLinePoint1;
Transform collisionLinePoint2;
public int health = 100;
Animator alienAnime;
Rigidbody2D rb;
bool colliding;
GameObject player;
public Player_Control playerControl;
Rigidbody2D playerRb;
void Awake()
{
player = GameObject.FindWithTag ("Player");
collisionLinePoint1 = transform.FindChild ("collision_S");
collisionLinePoint2 = transform.FindChild ("collision_E");
collisionLinePoint1.localPosition = new Vector3 (1.15f, 1.82f, 0f);
collisionLinePoint2.localPosition = new Vector3 (1.15f, -1.94f, 0f);
}
// Use this for initialization
void Start () {
playerRb = player.GetComponent<Rigidbody2D> ();
alienAnime = GetComponent<Animator> ();
rb = GetComponent<Rigidbody2D>();
player.GetComponent<Rigidbody2D> ();
}
void Update () {
Death ();
if (Input.GetButtonDown ("Fire3")) {
// Doesnt work correct???
playerRb.AddForce (transform.right * 400);
// This works fine
playerRb.AddForce (transform.up * 400);
}
}