This works:
public void ShootToTheRight(){
Rigidbody2D bulletInstance = Instantiate(cannonball, transform.position, Quaternion.Euler(new Vector2(0,0))) as Rigidbody2D;
bulletInstance.velocity = new Vector2(setSpeed(), 0);
}
This does not (it shoots, but to the right):
public void ShootToTheLeft(){
Rigidbody2D bulletInstance = Instantiate(cannonball, transform.position, Quaternion.Euler(new Vector2(-1,0))) as Rigidbody2D;
bulletInstance.velocity = new Vector2(setSpeed(), 0);
}
I’ve read the docs and tutorials, but I’m missing something. A fresh set of eyes would be greatly appreciated.
this should point you in the right direction:
I appreciate the link. I played around with Vector2/Vector3 some more, but with no success. Then I tried altering the speed instead:
bulletInstance.velocity = new Vector2(setSpeed() * -1, 0);
This sends the bullets to the left. Hacky, but it works, so I guess I’ll take it.
have u tried -setSpeed() (negative value along the x axis)?