# Another question-\_-'

**URL:** <https://forum.kirupa.com/t/another-question--/115037>\
**Category:** Uncategorized\
**Created:** [July 5, 2004, 1:02am UTC](https://forum.kirupa.com/t/another-question--/115037 "2004-07-05T01:02:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Moopers](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@Moopers](https://forum.kirupa.com/u/Moopers)\
**Post date:** [July 5, 2004, 1:02am UTC](https://forum.kirupa.com/t/another-question--/115037/1 "2004-07-05T01:02:43Z")

</div>

ok, i know i’ve been making a lot of threads but this will probably be the last question i want to ask in a while.

so i’ve got this enemy. i want him so that if he hits a (invisible wall), he turns around and walks back.

so, this is the script i’ve got so far, but it doesn’t seem to work.  
(this script is on the enemy)

onClipEvent (load){  
\_x-=random(3)+1;  
}

onClipEvent (enterFrame){  
if (this.hitTest(\_root.wall)){  
\_rotation=180;  
\_x+=random(3)+4;  
}  
}

any suggestions?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 5, 2004, 5:36am UTC](https://forum.kirupa.com/t/another-question--/115037/2 "2004-07-05T05:36:13Z")

</div>

well the way you have it set it will only move him one time. So maybe you could try something like…

[AS]  
onClipEvent (load) {  
speed = 3;  
}

onClipEvent (enterFrame) {  
\_x += speed;  
if (this.hitTest(\_root.wall)) {  
speed \*= -1;  
}  
}  
[/AS]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 6, 2004, 1:20am UTC](https://forum.kirupa.com/t/another-question--/115037/3 "2004-07-06T01:20:49Z")

</div>

wow cool. thanks Elbudster. this is a great forum:D

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 6, 2004, 1:35am UTC](https://forum.kirupa.com/t/another-question--/115037/4 "2004-07-06T01:35:17Z")

</div>

I try 🅱
