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

#1 2012-11-30 13:13:19

bongjoochung
New Scratcher
Registered: 2012-11-30
Posts: 2

How to make my bullet go back to gun as soon as it touches the enemy

When my bullet is fired, instead of just stopping when hitting one enemy, it just penetrates it and destroy everything in its path. I need to make so that one bullet kills only one enemy. What am I doing wrong here?

My script for bullet:

when green flag clicked
go to barrel
hide
forever
  if key space pressed
     point in direction direction of barrel
     go to barrel
     show
     repeat until touching edge or touching color of the enemy
        move 10 steps
    if touching color of the enemy
        hide
        go to barrel
    if touching edge
        hide
        go to barrel

Offline

 

#2 2012-11-30 13:21:42

laser314
Scratcher
Registered: 2010-07-16
Posts: 100+

Re: How to make my bullet go back to gun as soon as it touches the enemy

Make the enemy detect the bullet.


http://alpha.scratch.mit.edu/scratchr2/static//images/logo_sm.png 2.0 Alpha Tester!http://i49.tinypic.com/1zckcqb.png

Offline

 

#3 2012-11-30 13:24:25

bongjoochung
New Scratcher
Registered: 2012-11-30
Posts: 2

Re: How to make my bullet go back to gun as soon as it touches the enemy

could you give me a little more details, plz?  sad

Offline

 

#4 2012-11-30 13:44:25

laser314
Scratcher
Registered: 2010-07-16
Posts: 100+

Re: How to make my bullet go back to gun as soon as it touches the enemy

Without being able to see the project's full scripts, these are the most details I can give.
Make sure this script(Or something like it; adapt to your needs) is in the enemy.

when gf clicked
forever if <touching [bullet v]?>
put the script that makes the enemy die here
broadcast [enemykilled v] and wait
end
And put this in the bullet:
when I receive [enemykilled v]
go to [barrel v]
If you upload the project that you need help with, I can probably give more details.

Last edited by laser314 (2012-11-30 13:45:02)


http://alpha.scratch.mit.edu/scratchr2/static//images/logo_sm.png 2.0 Alpha Tester!http://i49.tinypic.com/1zckcqb.png

Offline

 

#5 2012-11-30 14:48:02

JH1010
Scratcher
Registered: 2012-05-31
Posts: 1000+

Re: How to make my bullet go back to gun as soon as it touches the enemy

laser314 wrote:

when I receive [enemykilled v]
go to [barrel v]

A better script for what you want would be:

when I receive [enemykilled v]
glide (1) secs to x:<[x position v]of[barrel v]>y:<[y position v]of[barrel v]>

Last edited by JH1010 (2012-11-30 14:48:28)

Offline

 

#6 2012-11-30 15:09:24

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: How to make my bullet go back to gun as soon as it touches the enemy


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#7 2012-11-30 21:08:08

pokemongardevoir
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: How to make my bullet go back to gun as soon as it touches the enemy

Put at the bullet something like this

[When I recieve Shoot]
[Set Direction to Direction of Gun]
[repeat until [ [touching enemy] or [touching edge] ]
[   ]   [move 1 step]
[   ]  [   ]    [  ]   [  ]
[Go to sprite gun]


That's what I'd use, no variables or broadcasts required ^^


http://i48.tinypic.com/n50dt.gifhttp://tiny.cc/oj6plwhttp://tiny.cc/creepforum
My website has been approved by the Scratch Team.  (^_^)

Offline

 

#8 2012-12-01 00:23:27

laser314
Scratcher
Registered: 2010-07-16
Posts: 100+

Re: How to make my bullet go back to gun as soon as it touches the enemy

JH1010 wrote:

laser314 wrote:

when I receive [enemykilled v]
go to [barrel v]

A better script for what you want would be:

when I receive [enemykilled v]
glide (1) secs to x:<[x position v]of[barrel v]>y:<[y position v]of[barrel v]>[/quote]
How is that better?

Last edited by laser314 (2012-12-01 00:23:36)


http://alpha.scratch.mit.edu/scratchr2/static//images/logo_sm.png 2.0 Alpha Tester!http://i49.tinypic.com/1zckcqb.png

Offline

 

Board footer