Help with NPC for sniping game. Part 2

Last time, I managed to make NPC civilian(aka good people), start running when I killed one of them or miss my sniper shot. Now I need to know how to make NPC police came out of the game screen and stop at random distance close to the middle of the game screen and start attacking me.

Could you please share some screenshots of your event or just a drawn of what you exactly want to do

i think he is making something like gta

Sorry for the question. Maybe I’ll try to figure it out myself first and then I come back again.

So here is a rough sketch of what I’m saying:

At the third panel, I want to make the NPC Cop stop at random distances away from each other. Then I’ll make an attack animation for the Cop. Can you help?


Make a cop spawner at position Player.X()+number which creates it outside the camera; Player.Y()+same like that,
And if shot is fired, pick a random cop spawner, create cop from copspawner.x() and copspawner.Y()

1 Like

Thank you, your drawing is clear.
So you want to do three things after a shot is fired:

  1. Cops run into the screen, around the center
  2. When at center, stop running
  3. Start shooting at player character

Mixen is correct on making the cops appear.

Here’s event sheets to make the cop move and then shoot:

I used 400 + Random(100) to make it so the cop come somewhere between 400 and 500 X position. Here’s an example:


They move to slightly different position each time.
Hope it helps

Unfortunately, there are no player character. Instead the player move a crosshair using their mouse. Attack is done by having the cursor on a target and then left click. Sorry that I didn’t mention this in the first place.

That’s ok, does Mixen and my post answer your question though?

Yes, both of you did. I appreciate it very much! Thank you.


By the way, about the attack part. I add an attack animation for the cop and now what should I do? (Sorry that I’m a little short of word)

Is it top-down? If yes, then rotate towards Player, change the animation to shoot and
if shoot animation then create bullet from Cop.PointX(“bulletpoint”) and Cop.Y(“bulletpoint”) and add a force towards Cop.angle

There are not player character, unfortunately. The player move a crosshair with the mouse and attack by left click on the target. Simply put, the cop attacks the player in front of the screen. (Sorry I didn’t told you about that)

I mean, if current animation is shoot animation then

I get the feeling this game is more of a first person shooter, like Operation Wolf, where you look into the scene though the eyes of the “player character” :


You’ll need to determine a position near the centre of the screen (use ScreenWidth()/2 and ScreenHeight()/2 for screen centre x & y), adding a random value to both. Then maybe look at tweening the police to that position, and attack once they’re in place. Play the attack animation, and reduce the player’s health.

1 Like

Yes, that’s what I mean. Gosh, I’m a little forgetful with word.

Sorry, but I still can’t understand. Can you explain a little more?

Move the police with (remember to add the tween behaviour to the police object):

Then have an event with this condition:


and add the actions to play the attack animation.

Sorry, but it didn’t turn out quite well. Also, the tweening somehow make the preview incredibly slow when I add easing over 2000 like you.

You can speed up the tweening by decreasing the 2000ms (2 seconds) say to 1000ms (1 second). Remember to only add the tween to one of the police, and to have a trigger once or check it doesn’t already exist (which is a tween condition)