Trying to get Player to shoot in both directions depending on what side he is facing?
Hi guys,
So currently in my off time from university and work I'm working on a shooting 2D platformer game with a boss level, and I have one current ongoing issue in that I'm trying to get my player to shoot in the opposite direction, as he currently shoots in just the right direction, even if he's clearly facing left.
Here is the shooting code at the minute (I'm coding in C#):
public bool shooting;
public bool facingRight = true;
if (Input.GetKeyDown (KeyCode.Period) && facingRight == true) {
shooting = true;
GameObject newBullet = Instantiate (bullet, transform.position, transform.rotation) as GameObject;
Destroy (newBullet, 5);
} else {
shooting = false;
}
I'm very much a beginner of the Unity engine and the programming language C#, but I'm unsure as to where to begin with setting the condition that the bullet will go the opposite way when the player shoots, and is facing in that direction.
Thanks in advance guys, and inform me if you think I haven't provided enough clear details.
:)
Your answer
Follow this Question
Related Questions
C# 2D Shooting a bullet based on player direction 1 Answer
Instantiate position for shooting projectile is way off. Could I get some help? 0 Answers
Can anybody tell me how to display text on axis? 1 Answer
Make bullet face direction of movement 1 Answer
Make enemy face left or right depending on player position 1 Answer