Ok im making an rpg game that is kind of like grand theft auto. I figured out how to make the character go through doors and move around and rotate too. By the way its a birds eye view game with 3d buildings. One thing i cant figure out is how if i hit a building a character will stop right there. With the script i have now when he goes up to the building he doesnt go through it but the buidling still moves and it pushes the character with it. Here is the actions i have on the character
onClipEvent (load){movespeed = 0;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
play();
_rotation = 90;
_x+= movespeed;
}
if (Key.isDown(Key.LEFT)) {
play();
_rotation = 270;
_x-= movespeed;
}
if (Key.isDown(Key.UP)) {
play();
_rotation = 0;
_y-= movespeed;
}
if (Key.isDown(Key.DOWN)) {
play();
_rotation = 180;
_y+= movespeed;
}
if (Key.isDown(Key.RIGHT) && Key.isDown(Key.UP)) {
_rotation = 45;
}
if (Key.isDown(Key.LEFT) && Key.isDown(Key.UP)) {
_rotation = 315;
}
if (Key.isDown(Key.RIGHT) && Key.isDown(Key.DOWN)) {
_rotation = 135;
}
if (Key.isDown(Key.LEFT) && Key.isDown(Key.DOWN)) {
_rotation = 225;
}
}onClipEvent (load) {
power = 0;
radius = 6;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_x -= power;
}
if (Key.isDown(Key.RIGHT)) {
_x += power;
}
if (Key.isDown(Key.UP)) {
_y -= power;
}
if (Key.isDown(Key.DOWN)) {
_y += power;
}
while (_root.wall.hitTest(_x, _y+radius, true)) {
_y–;
}
while (_root.wall.hitTest(_x, _y-radius, true)) {
_y++;
}
while (_root.wall.hitTest(_x-radius, _y, true)) {
_x++;
}
while (_root.wall.hitTest(_x+radius, _y, true)) {
_x–;
}
}
And here is what i have on the building
onClipEvent (load) {
movespeed = 3;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_x-= movespeed;
}
if (Key.isDown(Key.LEFT)) {
_x+= movespeed;
}
if (Key.isDown(Key.UP)) {
_y+= movespeed;
}
if (Key.isDown(Key.DOWN)) {
_y-= movespeed;
}
}
I gave the character the instance man and i gave the buildings the instance name wall.
Does anyone see any flaws in this code? If so please help me out.
Also if anyone wants to help with game i could use some. I would post the swf file on here but i have no clue how… Thanks