Firing bullets at a hero who is moving with a constrained X position

Hi,
I'm working on a game where my hero moves right in a side scrolling top-view game, but I am constraining his X position so that he does not move across more than half the screen. I give the effect that he's moving right by making the background scroll left, as long as my hero is moving right. As a side note, my hero is able to move left, but the background does not scroll in that case, and my hero can touch the left side of the screen. So what I've described above gives the impression that my hero can only make progress by moving to the right. When my hero is moving right, I have enemy actors that appear from the right (positioned above or below my hero on the Y-axis) and shoot bullets at him. The bullets have a behavior to move towards the position of the hero. The enemy actors continue to move left passed my hero, as long as my hero is moving right.

Here's the challenge I'm running into. When my hero is moving right and he's reached the constrained position X (but it still looks like he's moving right because the background is scrolling left), when the enemy actors appear and shoot at my hero, since my hero is constrained at a certain X position, the bullets will always hit my hero, even though there's the appearance that he's moving right and should theoretically be able to dodge the bullets. Of course, I understand that the moving background only gives the impression that my hero is moving to the right and has no effect on the bullets fired by the enemy actors. But, I'm at a loss as how to make it seem like the bullets should miss my hero because he's "moving" to the right and should not be hit because the bullets were targeted at a position that is now "behind" my hero.

I hope this makes sense. Does anyone have any thoughts? Just want to add that constraining the X position was the only way I knew to make it so that my hero did not walk off the right edge of the screen, while also making it seem like he was progressing to the right. The constrain camera didn't do the trick.

Thanks!

Comments

Sign In or Register to comment.