hi there! I just recently made a slope detection prototype that works with jumping. but sadly it crashes when the player touches the wall. can you help me?
btw the code is:
player.onEnterFrame = function() {
if(player._currentframe == 2 or player._currentframe == 3 or player._currentframe == 1&&_root.ground.hitTest(_x,_y,true)){
back = player._y;
front = player._y;
center = player._y;
while (ground.hitTest(player._x-20, back, true)) {
back -= 1;
}
while (!ground.hitTest(player._x-20, back-1, true)) {
back += 1;
}
while (ground.hitTest(player._x+20, front, true)) {
front -= 1;
}
while (!ground.hitTest(player._x+20, front+1, true)) {
front += 1;
}
while (ground.hitTest(player._x, center, true)) {
center -= 1;
}
while (!ground.hitTest(player._x, center+1, true)) {
center += 1;
}
player._y = center;
player._rotation = Math.atan2(front-back, 40)*180/Math.PI;
}
}
modified version of someone's code in a slope detection topic somewhere here. I modified it to work when jumping. just simple if conditions to modify it :p
EDIT:
errm please dont steal it
and I Like Pie
"Imagination is more important than knowledge." - Albert Einstein
