View Full Version : Gravity / Side Stopping / hitTest
stickmoose
March 9th, 2005, 07:31 PM
Hey, I've had this really irritating problem with a game i've currently been working on. Whenever you try to run next to a crate and jump you can double jump and sometimes get stuck. It's really wierd, but I think it's something to do with my hitTest boxes. I used transparent movieclips with the hitTest script in them. Here is the game engine with 5 levels for you to see. http://www.227movies.com/stickm/stuntman.html
If you need anything else, like my scripts, just ask and I will post.
Thanks!
-Stickmoose
Marz
March 9th, 2005, 08:01 PM
When hitTesting, especially with bounding boxes like you are doing. After you are done doing a hitTest, I would suggest moving the character by a couple of pixels to the direction that you are testing. If you hit it to the left, move your character a couple pixels to the left.
What I would ultimely suggest is this... Testing your character one space ahead before you move your character.
stickmoose
March 9th, 2005, 09:36 PM
When hitTesting, especially with bounding boxes like you are doing. After you are done doing a hitTest, I would suggest moving the character by a couple of pixels to the direction that you are testing. If you hit it to the left, move your character a couple pixels to the left.
What I would ultimely suggest is this... Testing your character one space ahead before you move your character.
Thanks for the reply, i'll try that out and let you know how it turns out. Thanks!
stickmoose
March 9th, 2005, 09:45 PM
Hmm, I don't really know how I would implement something like that into my hitTesting code... Here is what it looks like (the function that goes on objects to stop things when they hit it.
function gravity(object) {
for (i=0; i<_root.gravityObjects.length; i++) {
if (_root.gravityObjects[i] == "player") {
if (object.hitTest(_root.player.feet)) {
_root.player._y += -_root.player.ySpeed;
_root.player.ySpeed = 0;
if (_root.player.jumping == true) {
_root.player.jumping = false;
}
}
} else {
if (object.hitTest(_root[_root.gravityObjects[i]])) {
_root[_root.gravityObjects[i]]._y += -_root[_root.gravityObjects[i]].ySpeed;
_root[_root.gravityObjects[i]].ySpeed = 0;
if (_root[_root.gravityObjects[i]].jumping == true) {
_root[_root.gravityObjects[i]].jumping = false;
}
}
}
}
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.