I am having so much trouble with this!!! :@ I've posted the same thing on so many sites without getting any good help!!! So plz help me if you come across this!!!!
I've made it so my character can walk along slopes but he dosn't really stick to the ground and it's really choppy not to mention he cant walk up slopes that are too steep!!
========================================================================
Heres a link to the game
http://spamtheweb.com/ul/upload/290809/78070_stickman_odo_5.php
+=======================================================================
Here is the actionscript to my game!!
====================================================
onClipEvent (load) {
var dir = 1;
var jmp:Boolean = false;
var grav:Number = 0;
var speed:Number = 10;
var jumpHeight:Number = 9;
var slow:Number = .7;
var slowspd:Number = speed/1.5;
var setspeed:Number = speed;
var scale:Number = _xscale;
var ex:Number = 5;
rotation = 0;
this.gotoAndStop(2);
}
onClipEvent (enterFrame) {
grav++;
_y += grav;
while (_root.ground.hitTest(_x, _y, true)) {
_y--;
grav = 0;
}
back = player._y;
front = player._y;
center = player._y;
if (slope.hitTest(player._x-20, back, true)) {
back -= 1;
}
if (!slope.hitTest(player._x-20, back-1, true)) {
back += 1;
}
if (slope.hitTest(player._x+20, front, true)) {
front -= 1;
}
if (!slope.hitTest(player._x+20, front+1, true)) {
front += 1;
}
if (slope.hitTest(player._x, center, true)) {
center -= 1;
}
if (!slope.hitTest(player._x, center+1, true)) {
center += 1;
}
player._y = center;
p1._x = player._x+20;
p2._x = player._x-20;
p1._y = front;
p2._y = back;
player._rotation = Math.atan2(front-back, 40)*180/Math.PI;
ang = (char._rotation)*(Math.PI/180);
char._x += yspeed*Math.sin(ang);
char._y += yspeed*Math.cos(ang);
char._x += xspeed*Math.cos(ang);
char._y += xspeed*Math.sin(ang);
ang = char._rotation/57.3;
if (!jmp) {
char._x += speed*Math.cos(ang);
char._y += speed*Math.sin(ang);
if (!(char.hitTest(ground))) {
jmp = true;
xv = speed*Math.cos(ang);
yv = speed*Math.sin(ang);
}
} else if (jmp) {
yv += 0.4;
char._y += yv;
char._x += xv;
}
if (_root.ground.hitTest(_x, _y+3, true)) {
}
while (_root.ground.hitTest(_x, _y, true)) {
_y--;
grav = 0;
jmp = false;
}
if (_root.water.hitTest(_x, _y, true)) {
if (grav>0) {
grav *= slow;
}
speed = slowspd;
} else {
speed = setspeed;
}
if (Key.isDown(Key.RIGHT)) {
_x += speed;
_xscale = scale;
this.dir = 1;
if (_root.ground.hitTest(_x, _y+3, true)) {
this.gotoAndStop(1);
} else {
this.gotoAndStop(2);
}
} else if (Key.isDown(Key.LEFT)) {
_x -= speed;
_xscale = -scale;
this.dir = -1;
if (_root.ground.hitTest(_x, _y+3, true)) {
this.gotoAndStop(1);
} else {
this.gotoAndStop(2);
}
} else {
if (_root.ground.hitTest(_x, _y+3, true) && !Key.isDown(1) && !Key.isDown(1)) {
this.gotoAndStop(3);
}
}
if (Key.isDown(Key.SPACE) && _root.ground.hitTest(_x, _y+3, true)) {
grav = -jumpHeight;
_y -= 4;
jmp = true;
this.gotoAndStop(2);
}
if (_root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/2), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/6), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-_height, true)) {
_x -= speed;
}
if (_root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/2), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/6), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-_height, true)) {
_x += speed;
}
if (_root.ground.hitTest(_x, _y-_height-15, true)) {
grav = 1;
}
if (jmp=true && deg>90) {
this._rotation*.001;
}
this._xscale = this.dir*Math.abs(this._xscale);
}
====================================================================
Portal
