hitTest problem (in game)

Hi! could someone tell me how to make the character walk up the hill instead of through it!? I don’t want him to be able to walk through any part of the ground mc, from any direction…:a:

Hope some1 can help!!!:ne:

Here’s my game…:smiley:

Link: hem.bredband.net/ollij

2 topics for that 0.o

sorry for duble posting!!!8-]

Didn’t think it worked the first time!

use a while+ hitTest, then you can just modify your ground with the bump… and ANY hill in the ground will work


while(ground.hitTest(char._x, char._y, true)){
char._y--;
}

:wink:

I can’t get it to work!! :h:

where exactly am I going to put this as?
:ko:

whereever you have th characters current code

It doesn’t work!
What’s wrong?
Can someone tell me what to do!?:wink:

Here’s my actionscript:

 
onClipEvent (load) {
 jumping = false;
 falling = true;
 speed = 0;
 jump = 14;
 healthX = _root.health._x;
 scoreX = _root.score._x;
 Xpos = this._x;
 Ypos = this._y;
 maxmove = 15;
 _root.maxshoottime = 100;
}
onClipEvent (enterFrame) {
 _x = Xpos-_root._x;
 _root.score._x = scoreX-_root._x;
 _root.health._x = healthX-_root._x;
 if (!_root.ground.hitTest(this._x, this._y, true) && !jumping) {
  this._y += 6;
 }
 if (!_root.shooting) {
  _root.timer = 0;
  _root.mvsp = _xscale/20;
 }
 if (_root.dead) {
  this.gotoAndStop("dead");
 } else {
  speed *= .85;
  if (dir == "right" && !_root.leftblock.hitTest(this._x+20, this._y, true)) {
   _root.health._x += speed;
   _root.score._x += speed;
   _root.icons._x += speed;
   _root.menu._x += speed;
   _root.playagain._x += speed;
   _root.mainmenu._x += speed;
   _root.BG._x += speed;
   _root.hell._x += speed;
   this._x += speed;
   _root._x -= speed;
  }
  if (speed>0) {
   dir = "right";
  } else if (speed<0) {
   dir = "left";
  }
  if (dir == "left" && !_root.rightblock.hitTest(this._x-20, this._y, true)) {
   _root.health._x += speed;
   _root.score._x += speed;
   _root.icons._x += speed;
   _root.menu._x += speed;
   _root.hell._x += speed;
   this._x += speed;
   _root._x -= speed;
  }
  if (Key.isDown(Key.LEFT)) {
   if (speed>-maxmove) {
    speed--;
   }
   this.gotoAndStop("run");
   this._xscale = -100;
  } else if (Key.isDown(Key.RIGHT)) {
   if (speed<maxmove) {
    speed++;
   }
   this._xscale = 100;
   this.gotoAndStop("run");
  } else if (Key.isDown(Key.CONTROL)) {
   this.gotoAndStop("attack");
   attacking = true;
   speed = 0;
  } else if (Key.isDown(Key.SPACE)) {
   if (_root.gotgun == true && !_root.shooting) {
    _root.attachMovie("bullet", "bulleter", 1, {_x:_root.char._x, _y:_root.char._y-25});
    _root.shooting = true;
    with (_root.bulleter) {
     onEnterFrame = function () {
      if (_root.timer>_root.maxshoottime) {
       _root.shooting = false;
       unloadMovie(this);
      }
      _root.timer++;
      _x += _root.mvsp;
     };
    }
    attacking = true;
    speed = 0;
    this.gotoAndStop("shoot");
   }
  } else if (speed<1 && speed>-1 && !attacking) {
   speed = 0;
   this.gotoAndStop("idle");
  }
  if (Key.isDown(Key.UP) && !jumping) {
   jumping = true;
  }
  if (jumping) {
   this.gotoAndStop("jump");
   this._y -= jump;
   jump -= .5;
   if (jump<0) {
    falling = true;
   }
   if (jump<-15) {
    jump = -15;
   }
  }
  if (falling) {
   this.gotoAndStop("fall");
  }
  if (Key.isDown(Key.DOWN)) {
   this.gotoAndStop("duck");
  }
  if (_root.ground.hitTest(this._x, this._y, true) && falling) {
   jump = 12;
   jumping = false;
   falling = false;
  }
 }
}
onClipEvent (keyUp) {
 if (Key.getCode() == Key.CONTROL) {
  attacking = false;
 }
}


Tried the code use it under the onClipEvent(enterFrame){


while(_root.ground.hitTest(_root.char._x, _root.char._y, true)){
_root.char._y--;
}

try that

Thanks! It finaly works!!!
:stare: =) :drool: :asian: :stare:

you got nice graphics for that game by the way :thumb: