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

#1 2011-05-08 20:27:14

bdn7
Scratcher
Registered: 2010-07-10
Posts: 100+

Multiple AI Sensors.

I am making a game with artificial intelligence zombies, and have all of the direction and walking programmed. But the problem is that it is a platformer and the zombies can walk through walls. This wouldn't be a problem if I only had one, but I have lots. Too many to program individual sensors for each one. How can I make lots of zombies that can't walk through walls without me having to program each one's sensors?


http://i.imgur.com/Q7PiV.png
That's right. My text is BLUE.

Offline

 

#2 2011-05-08 20:33:54

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

Re: Multiple AI Sensors.

Sensor costumes could work.  It's like a sensor sprite, but a costume that your sprite switches to and acts as a sensor.  Say you make an extra costume that's just a dot (with it's rotation sensor placed such that the sprite is on the right side of your main costume)  You can add into your main script:

switch to costume [right sensor]
if touching [wall]
   Set RightTest to 1
else
   Set RightTest to 0
switch to costume [main costume]

*Note: Your main costume won't be affected and you won't see the sensor.

If you're using color sensing, you can have just one sensing costume with four colors on each side.

Last edited by Kileymeister (2011-05-08 20:34:56)


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 2011-05-08 20:39:58

bdn7
Scratcher
Registered: 2010-07-10
Posts: 100+

Re: Multiple AI Sensors.

Kileymeister wrote:

Sensor costumes could work.  It's like a sensor sprite, but a costume that your sprite switches to and acts as a sensor.  Say you make an extra costume that's just a dot (with it's rotation sensor placed such that the sprite is on the right side of your main costume)  You can add into your main script:

switch to costume [right sensor]
if touching [wall]
   Set RightTest to 1
else
   Set RightTest to 0
switch to costume [main costume]

*Note: Your main costume won't be affected and you won't see the sensor.

If you're using color sensing, you can have just one sensing costume with four colors on each side.

Thanks! I'll try that.


http://i.imgur.com/Q7PiV.png
That's right. My text is BLUE.

Offline

 

#4 2011-05-09 18:05:22

bdn7
Scratcher
Registered: 2010-07-10
Posts: 100+

Re: Multiple AI Sensors.

Kileymeister wrote:

Sensor costumes could work.  It's like a sensor sprite, but a costume that your sprite switches to and acts as a sensor.  Say you make an extra costume that's just a dot (with it's rotation sensor placed such that the sprite is on the right side of your main costume)  You can add into your main script:

switch to costume [right sensor]
if touching [wall]
   Set RightTest to 1
else
   Set RightTest to 0
switch to costume [main costume]

*Note: Your main costume won't be affected and you won't see the sensor.

If you're using color sensing, you can have just one sensing costume with four colors on each side.

This doesn't seem to work. For one, the zombies have walking animations, and two it puts the right and left  variables to one, even when the sensors aren't touching the wall.


http://i.imgur.com/Q7PiV.png
That's right. My text is BLUE.

Offline

 

Board footer