Commit dbd944a9 by Philipp Adolf

Make aim direction independent of localScale

parent f4e923ad
......@@ -96,6 +96,7 @@ public class PlayerControl : MonoBehaviour
velocity.y = 0;
updateDashDirection();
updateAimDirection();
if (canDash() && inputMapping.isDashPressed())
{
......@@ -242,6 +243,7 @@ public class PlayerControl : MonoBehaviour
private int powerUpType = POWERUP_NONE;
private bool coolingDown = false;
private float aimDirection = 1.0f;
public float coolDownTime = 2.0f;
......@@ -258,17 +260,28 @@ public class PlayerControl : MonoBehaviour
}
private void updateAimDirection()
{
if (inputMapping.isRightPressed())
{
aimDirection = 1.0f;
}
else if (inputMapping.isLeftPressed())
{
aimDirection = -1.0f;
}
}
private void shoot()
{
float dir = -Mathf.Sign(transform.localScale.x);
Vector2 pos = ((Vector2) transform.position) + new Vector2(dir * spawnDistance, bulletYOffset);
Vector2 pos = ((Vector2) transform.position) + new Vector2(aimDirection * spawnDistance, bulletYOffset);
switch (powerUpType)
{
case POWERUP_HEALINGBULLET:
GameObject bullet = Instantiate(healingBulletPrefab, pos, transform.rotation) as GameObject;
bullet.transform.parent = deleteAllChildrenAtRestart;
bullet.GetComponent<Bullet>().shoot(new Vector2(dir, 0));
bullet.GetComponent<Bullet>().shoot(new Vector2(aimDirection, 0));
break;
default:
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment