Hi guys, i need a little help. I have a FlipSprite method. And i want to add bullets to my game. When im shooting right, its fine, but i can’t write the code to flip my bullet direction. Could you guys help me what i should write to my game to work?
My FlipSprite method and the running method:
private void FlipSprite()
{
bool playerHasHorizontalSpeed = Mathf.Abs(myRigidbody.velocity.x) > Mathf.Epsilon ;
if(playerHasHorizontalSpeed == true)
{
//reserve the currenct scaling of x axis
transform.localScale = new Vector2 (Mathf.Sign(myRigidbody.velocity.x),1f);
}
}
private void Run()
{
float controlThrow = CrossPlatformInputManager.GetAxis("Horizontal");
Vector2 runVelocity = new Vector2(controlThrow * runSpeed,
myRigidbody.velocity.y);
myRigidbody.velocity = runVelocity;
bool playerHasHorizontalSpeed = Mathf.Abs(myRigidbody.velocity.x) >
Mathf.Epsilon;
myAnimator.SetBool("Running", playerHasHorizontalSpeed);
}
Plus i have two other method bullet and weapon, but these only contains like if i press left click fire, and the bullet contains rb.velocity = transform.right * speed;