Relative position (enemy AI related... kinda)

OkyshoOkysho Member Posts: 158
edited November -1 in Working with GS (Mac)
I'm almost done with all of the game mechanics for my game (beta named Deadly Sin, for reference ease).

one of my enemies flies around, generally hovering around the player and fires at the player from the air. Since it's constantly moving, I can't make it strafe and blindly fire, so I incorporated a "move-to" action, but this is a bit to precise, making the enemy's shot completely unavoidable.

I've considered using a timer to change the player position attribute instead of constrain, but if that changes halfway through the enemy's AI, the shot might turn around in mid-air and it looks all silly and unnatural.

Does the community have any suggestions as to how I can have my enemy shoot at my player, but shoot at it's relative position, rather than homing in on it's exact position?

In advance, thanks!!

Comments

  • RattleheadRattlehead Member Posts: 485
    I was playing around with this awhile back and one of the things I played with (since I was doing as TSB indicated and tracking the players X and Y position), was adding in some variability by adding in a random call to the current X/Y position. By tweaking that I was able to get it to appear like some shots were close and if the player happened to walk into the shot it also somewhat looked like it was leading the player.

    This is actually how some 3D shooters do it as well when tracing a line towards the player. It's probably not the best but it works fairly well if you can get the numbers around the random call working right.

    Things to take into effect would be the size of the player actor, the current angle and distance between the player and the enemy, the speed at which both actors move...
  • OkyshoOkysho Member Posts: 158
    That sounds like that'll work better. I just kinda copped out and used the move-to which is where this problem arose from. I'll try that out and see. Sounds like it works already though. Thanks TSB and Rattlehead!
  • RattleheadRattlehead Member Posts: 485
    Let us know how it goes. It should do the trick until the GameSalad Skynet AI module comes out in 2018.

    I am hoping that one day I can write a tutorial or two on this topic but right now I am full ahead on 'real' work. :(
Sign In or Register to comment.