How do you make an enemy shoot at the player but not always hit him?
Incredibo
Member Posts: 274
okay so on my next game I want there to be two actors the player & the computer but i want the computer to shoot at the player but miss at time or hit at times is this possible"??/?
Regards,
Bo
Regards,
Bo
Comments
also your help is greatly appreciated
Creating two real game attributes and constrain them to the player actor's x & y position (eg player x and player y). Then on the actor thats being shot towards the player go:
accelerate towards/move to X coordinate: game.player X + random (-50,50;or whatever numbers you want)
Y coordinate: game.player Y + random (-50,50)
This way whenever the actor is shot at the player's actor it should shoot anywhere from 50 to the left, 50 to the right, 50 up and 50 below the actor and occasionally hit. Of course you'll have to continually deactivate and reactivate the random expression so that it stays random and since I've never dealt with that before I don't quite know how to do it :S, try searching "seed random expression" or something like that.
EDIT: obviously, the smaller the number spread in the random expression, the greater chance of hitting
VectorToAngle(game.playerX-self.positionX,game.playerY-self.positionY)relative to scene
Then in the bullet just have a move 0 to actor. This will only hit the hero if the hero does not move. But if the hero moves the bullet will go towards the spot that the hero was at when the shot was fired. So depending on how fast you set the move behavior to the hero will have time to get away.
Well both character want be moving they will just be shooting at each other from side to side??
so does the rules stiull apply
something like that
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left