This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-01-15 17:53:25

haloman298
New Scratcher
Registered: 2011-09-03
Posts: 18

How can you make Enemies that shoot at you?

I've got part of it figured out.
The enemy can run toward the player, then at a certain distance they will shoot.
I just want to know how to have them aim at you.  I guess you can have the arm with the gun a separate sprite to do this.

What should I do?

Offline

 

#2 2012-01-15 18:17:24

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: How can you make Enemies that shoot at you?

Once they are in position to shoot, they can broadcast a message that a bullet sprite receives to fire.  However, this would require a separate broadcast message for every enemy and a bullet sprite for every enemy.

You can insert a script like this into each bullet sprite:
http://img32.imageshack.us/img32/1143/scriptd.gif

And a script like this into each enemy sprite:
http://img708.imageshack.us/img708/6850/script.gif

Obviously I don't know specific numbers like the speed of the bullet or distance of the enemy but hopefully you get the idea.

Last edited by Kileymeister (2012-01-15 18:22:55)


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#3 2012-01-15 18:19:05

plb36
Scratcher
Registered: 2011-10-16
Posts: 100+

Re: How can you make Enemies that shoot at you?

If using the arm with the gun as a seperate sprite (this method looks more realistic) do
When distance to player < 50(or any number)
Point towards player
Broadcast Shoot

Then on the bullet put:
When I recieve shoot
point towards player
Repeat until touching player
Move 10 steps
wait 0.05 secs
End Repeat
Wait 0.5 Secs
Hide
Go To Enemy

That should work.


http://i1094.photobucket.com/albums/i456/plb36/myforumssig.png

Offline

 

#4 2012-01-15 19:08:40

haloman298
New Scratcher
Registered: 2011-09-03
Posts: 18

Re: How can you make Enemies that shoot at you?

The problem is that the arm sprite moves a little weird.  When the good guy sprite is behind the enemy, the arm goes down to the enemy's legs.  How can I get the arm to rotate from a fixed point on the enemy?

Offline

 

#5 2012-01-15 19:34:02

plb36
Scratcher
Registered: 2011-10-16
Posts: 100+

Re: How can you make Enemies that shoot at you?

Okay, try this.

If direction < (fixed point 1) and direction > (fixed point 2)
Point towards player
End If

For a better visual look at this

Hope this helps!


http://i1094.photobucket.com/albums/i456/plb36/myforumssig.png

Offline

 

#6 2012-01-15 19:42:58

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: How can you make Enemies that shoot at you?

plb36 wrote:

Okay, try this.

If direction < (fixed point 1) and direction > (fixed point 2)
Point towards player
End If

For a better visual look at this

Hope this helps!

That would probably cause the arms to get stuck once they leave those boundaries, I believe you meant this.

Last edited by Kileymeister (2012-01-15 19:43:43)


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#7 2012-01-15 20:17:32

plb36
Scratcher
Registered: 2011-10-16
Posts: 100+

Re: How can you make Enemies that shoot at you?

Kileymeister wrote:

plb36 wrote:

Okay, try this.

If direction < (fixed point 1) and direction > (fixed point 2)
Point towards player
End If

For a better visual look at this

Hope this helps!

That would probably cause the arms to get stuck once they leave those boundaries, I believe you meant this.

I see. You're right, that works better.


http://i1094.photobucket.com/albums/i456/plb36/myforumssig.png

Offline

 

#8 2012-01-15 21:58:21

haloman298
New Scratcher
Registered: 2011-09-03
Posts: 18

Re: How can you make Enemies that shoot at you?

It's not working.  The arm only follows the player on one side of the enemy.  What if the player is on the other side?  There's also some flickering in the arm.  What I meant was for the arm to rotate, but have its center (shoulder) at a fixed point.  I want the arm to pivot on that point.

Offline

 

#9 2012-01-15 21:59:00

12three
Scratcher
Registered: 2008-06-12
Posts: 1000+

Re: How can you make Enemies that shoot at you?

well if you hit an armed man in the face, he will shoot at you. im not sure if thats what you mean

Offline

 

#10 2012-01-16 07:56:39

plb36
Scratcher
Registered: 2011-10-16
Posts: 100+

Re: How can you make Enemies that shoot at you?

haloman298 wrote:

It's not working.  The arm only follows the player on one side of the enemy.  What if the player is on the other side?  There's also some flickering in the arm.  What I meant was for the arm to rotate, but have its center (shoulder) at a fixed point.  I want the arm to pivot on that point.

Okay, I see your problem.

First, go to the arm costume.
Now, click edit.
Click "Set Costume Center"
Align the center of the crosshairs with the point you want it to rotate around.

That should work (unlike the other two times I tried to help)

Hope this helps!


http://i1094.photobucket.com/albums/i456/plb36/myforumssig.png

Offline

 

#11 2012-01-16 08:14:05

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: How can you make Enemies that shoot at you?

plb36 has hopefully hit the nail on the head.  Sorry about us being unable to figure out the problem before.  That should do it, and I suggest to clean up any other cosmetic conundrums that to prevent the arms from being upside down when facing left, create a costume of the arms upside down and apply this script:
http://img189.imageshack.us/img189/6850/script.gif

Hopefully that doesn't confuse matters further.

Last edited by Kileymeister (2012-01-16 08:14:16)


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#12 2012-01-16 22:06:45

haloman298
New Scratcher
Registered: 2011-09-03
Posts: 18

Re: How can you make Enemies that shoot at you?

Actually, by just playing around with it I finally got it to work!  Thanks!

Offline

 

#13 2012-01-16 22:16:16

plb36
Scratcher
Registered: 2011-10-16
Posts: 100+

Re: How can you make Enemies that shoot at you?

I'm glad you got it! Happy scratching!


http://i1094.photobucket.com/albums/i456/plb36/myforumssig.png

Offline

 

#14 2012-01-16 22:31:51

CatPerson
Scratcher
Registered: 2011-12-17
Posts: 1000+

Re: How can you make Enemies that shoot at you?

ya just make the gun or whateves a separate sprite. then use the block that says "point foward " in the motion section then go to the down arrow and click " mouse pointer ". then that should be it   smile   tell me if you need more advice.

/\_/\
I ' . ' I  CatPerson - tell me if you like this cat and Ill make you an animal like this


http://nyopoliticker.files.wordpress.com/2012/02/in_dog_we_trust_rusty.jpghttps://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSrxH2RAmte9adghivuoOhgklIlUcZUFuCAA0wFufFq-NWyZWg5http://www.buttonsonline.com/2012/obama/BO-rallysign-104.gif

Offline

 

Board footer