Hit Test Problem

I have searched the foru and read the tutorial on how to do this so I tried to get my own code out of it…
What Im doing is I have a character and he can walk around… whenever he gets to a wall I want him to stop…
here is my code


onClipEvent (enterFrame) {
if (wall1.hitTest(getBounds(_root).xMax, _y, true)) {
				_x -= 1;
			}
			if (wall1.hitTest(getBounds(_root).xMin, _y, true)) {
				_x += 1;
			}
			if (wall1.hitTest(_x, getBounds(_root).yMax, true)) {
				_y -= 1;
			}
			if (wall1.hitTest(_x, getBounds(_root).yMin, true)) {
				_y += 1;
			}
}

All Help is appreciated

no body ?:q:

instead of _y, or _x -=1, try this._x or this._y

[SIZE=1][FONT=arial]Hmm… that didn’t work…[/FONT][/SIZE]

[SIZE=1][FONT=arial]Ok… now I’ve got this new code… it still doesn’t work… and I have no clue why…[/FONT][/SIZE]


onClipEvent (enterFrame) {
if (_root.walkingMarz, hitTest(_root.wall1)) {
		_root.gotoAndPlay(1);
	}
}

no one ?

dunno if this help i did this a few months ago:
http://membres.lycos.fr/mlkdesign/kirupa/circles.swf

http://membres.lycos.fr/mlkdesign/kirupa/circles.fla

oh and


onClipEvent (enterFrame) {
        if (_root.walkingMarz.hitTest(_root.wall1)) {
                _root.gotoAndPlay(1);
        }
}


wouldnt work because i guess youre confusing AS movement and frame handling…

should be


onClipEvent (enterFrame) {
        if (_root.walkingMarz.hitTest(_root.wall1)) {
                _root.gotoAndPlay(1);
        }
}

hmm i dont know whats wrong with this… I have basically a character… you can move him around with the arrow keys… i want it so that if you walk into a wall it will stop…
fluid_tw0:
yours didn’t work at all :frowning:
and
mlkdesign:
im using controlment using the arrow keys… your .fla is automated… im putting the actions on the character movieclip

here, this is a little something I’ve been working on. Nothing special, but it is exactly what u r looking for (i hope, sounds like it)

Please reply if it is.

Im :phil:

oops :slight_smile:

yes that is what i want… ill look at the code and see if it works

hmm i still cant get this… if anyone wants to look at my .fla im posting it

forgot it…
this isnt the actual copy but its just like it… real one is too big

I’m not sure, but I think this is what you’re looking for

scotty:?)

Wow… exactly… :A+:
Could you tell me how you did this?? I cant find the code that you did unless its in the Character MC

Ahh silly me… i see it… thanks for your help!!

You’re welcome;)