Disable movement in certain...
- klmai
-
klmai
- Member since: Dec. 24, 2008
- Offline.
-
- Forum Stats
- Member
- Level 03
- Blank Slate
Okay i'm just starting this lil game and im working on AI and character movement. I want so when the player bumps into the enemy, the player stops moving and the direction that goes with the side that hit the enemy is disabled, but the others are not. So the enemy would act as a wall you could travel around.
I've tried multiple things but it just turns out buggy. Dont mind the pgo variable, its not important atm.
onClipEvent (enterFrame) {
speed = 6;
if (Key.isDown(87) && _root.pgo == false) {
this._y -= speed;
this._rotation = 0;
}
if (Key.isDown(83) && _root.pgo == false) {
this._y += speed;
this._rotation = 180;
}
if (Key.isDown(68) && _root.pgo == false) {
this._x += speed;
this._rotation = 90;
}
if (Key.isDown(65) && _root.pgo == false) {
this._x -= speed;
this._rotation = 270;
}
if (Key.isDown(65) && _root.pgo == false) {
if (Key.isDown(83)) {
this._rotation = 220;
}
}
if (Key.isDown(65) && _root.pgo == false) {
if (Key.isDown(87) && _root.fight == false) {
this._rotation = 320;
}
}
if (Key.isDown(68) && _root.pgo == false) {
if (Key.isDown(83) && _root.pgo == false) {
this._rotation = 130;
}
}
if (Key.isDown(68) && _root.pgo == false) {
if (Key.isDown(87) && _root.pgo == false) {
this._rotation = 45;
}
}
} - nuclearstickman5
-
nuclearstickman5
- Member since: Aug. 30, 2006
- Offline.
-
- Forum Stats
- Member
- Level 14
- Blank Slate
well try this. Give your player an instance name of player and give your enemy an instance name of enemy. Go inside your player and insert an extra keyframe. Put a stop action in all the keyframes. Now delete your character from the new frame you made and re draw him or duplicate him or w/e. Then go out of your player and add this action to it.
onClipEvent (enterFrame) {
if(_root.player.hitTest(_root.enemy)){
_root.player.gotoAndStiop(PUT WHAT EVER NUMBER THE FRAME IS THAT YOU MADE INSIDE YOUR PLAYER);
}
} .
- nuclearstickman5
-
nuclearstickman5
- Member since: Aug. 30, 2006
- Offline.
-
- Forum Stats
- Member
- Level 14
- Blank Slate
sorry for double post. made a slight mistake in the action script.
onClipEvent (enterFrame) {
if(_root.player.hitTest(_root.enemy)){
_root.player.gotoAndStiop(PUT WHAT EVER NUMBER THE FRAME IS THAT YOU MADE INSIDE YOUR PLAYER);
}
} .
- nuclearstickman5
-
nuclearstickman5
- Member since: Aug. 30, 2006
- Offline.
-
- Forum Stats
- Member
- Level 14
- Blank Slate
Omg! triple post?? Please forgive me!! But Silly ole me messed up on it again. lol im so so sorry.
onClipEvent (enterFrame) {
if(_root.player.hitTest(_root.enemy)){
_root.player.gotoAndStop(PUT WHAT EVER NUMBER THE FRAME IS THAT YOU MADE INSIDE YOUR PLAYER);
}
} .
- klmai
-
klmai
- Member since: Dec. 24, 2008
- Offline.
-
- Forum Stats
- Member
- Level 03
- Blank Slate
That wouldnt do shit, you obviously dont understand what i need. I need so that if i was going to the right and i hit the enemy, i couldnt move right anymore and id have to move in another direction to get away from the enemy and move right again.
- BillysProgrammer
-
BillysProgrammer
- Member since: Sep. 17, 2008
- Offline.
-
- Forum Stats
- Member
- Level 16
- Gamer
check if there hitTesting
Player Code:
if(this.hitTest(_root.enemy)) {
speed = 0;
} - klmai
-
klmai
- Member since: Dec. 24, 2008
- Offline.
-
- Forum Stats
- Member
- Level 03
- Blank Slate
At 2/7/09 07:23 PM, BillysProgrammer wrote: check if there hitTesting
Player Code:
if(this.hitTest(_root.enemy)) {
speed = 0;
}
but then it would just disable movement in all directions. Fuck, no one understands what i need.
its like...
if going right and hits enemy on right side, cannot move right because enemy is there, must move dif direction to get around the enemy.
- scy1192
-
scy1192
- Member since: Feb. 7, 2009
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
This tutorial found might help.
- klmai
-
klmai
- Member since: Dec. 24, 2008
- Offline.
-
- Forum Stats
- Member
- Level 03
- Blank Slate
Is every one fucking retarded???~!?!?!??! read what i need! fuck.
- scy1192
-
scy1192
- Member since: Feb. 7, 2009
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
Yes, I did read.
Your obstacle is like a wall. Just apply the AS for a wall to the character and it should work.
- klmai
-
klmai
- Member since: Dec. 24, 2008
- Offline.
-
- Forum Stats
- Member
- Level 03
- Blank Slate
At 2/8/09 01:17 AM, scy1192 wrote: Yes, I did read.
Your obstacle is like a wall. Just apply the AS for a wall to the character and it should work.
Youre a fucking retard. I dont need it to be a wall. The enemy follows you, if you hit him, you wont be able to move what ever direction that hit him. A simple hitTest wont do this! FUCK YOU!
- CrazyChihuahua
-
CrazyChihuahua
- Member since: Apr. 22, 2003
- Offline.
-
- Forum Stats
- Member
- Level 14
- Blank Slate
At 2/8/09 01:22 AM, klmai wrote:At 2/8/09 01:17 AM, scy1192 wrote: Yes, I did read.Youre a fucking retard. I dont need it to be a wall.
Your obstacle is like a wall. Just apply the AS for a wall to the character and it should work.
But in your first post...
So the enemy would act as a wall you could travel around.
I don't understand. What he said seems to make sense. If you are traveling to the right and hit the left side of the wall, it would stop the character from moving right. That's what you said you wanted. So why not use the same code you would use for a wall on a character?
Not that my post matters. You're just going to be a whiny ass in your response anyways.
- klmai
-
klmai
- Member since: Dec. 24, 2008
- Offline.
-
- Forum Stats
- Member
- Level 03
- Blank Slate
Not that my post matters. You're just going to be a whiny ass in your response anyways.
Sorry, its frustrating. And the enemy doesnt stretch across the screen, so id need 4 walls inside the enemy mc...cant believe i never thought of that.
- CrazyChihuahua
-
CrazyChihuahua
- Member since: Apr. 22, 2003
- Offline.
-
- Forum Stats
- Member
- Level 14
- Blank Slate
At 2/9/09 12:13 AM, klmai wrote:Not that my post matters. You're just going to be a whiny ass in your response anyways.Sorry, its frustrating. And the enemy doesnt stretch across the screen, so id need 4 walls inside the enemy mc...cant believe i never thought of that.
I'm a beginner in AS, but could you not test against the xMax or xMin values of the enemy (xMax being the right side of the enemy, xMin being the left), and have the code react accordingly?
- Denvish
-
Denvish
- Member since: Apr. 25, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (15,977)
- Block
-
- Forum Stats
- Member
- Level 46
- Blank Slate
Being abusive towards people who are trying to help you is not generally a good plan. You didn't actually clarify what kind of game you're making in your first post, so it's not really surprising you didn't get the answers you needed.
onClipEvent (enterFrame) {
speed = 6;
if (Key.isDown(87) && !_root.pgo) {
this._y -= speed;
this._rotation = 0;
while(this.hitTest(_root.enemy)){this._y += speed/10;}
}
if (Key.isDown(83) && !_root.pgo) {
this._y += speed;
this._rotation = 180;
while(this.hitTest(_root.enemy)){this._y -= speed/10;}
}
if (Key.isDown(68) && !_root.pgo) {
this._x += speed;
this._rotation = 90;
while(this.hitTest(_root.enemy)){this._x -= speed/10;}
}
if (Key.isDown(65) && !_root.pgo) {
this._x -= speed;
this._rotation = 270;
while(this.hitTest(_root.enemy)){this._x+= speed/10;}
}
if (Key.isDown(65) && Key.isDown(83) && !_root.pgo) {
this._rotation = 220;
}
if (Key.isDown(65) && Key.isDown(87) && !_root.pgo) {
this._rotation = 320;
}
if (Key.isDown(68) && Key.isDown(83) && !_root.pgo) {
this._rotation = 130;
}
if (Key.isDown(68) && Key.isDown(87) && !_root.pgo) {
this._rotation = 45;
}
} - klmai
-
klmai
- Member since: Dec. 24, 2008
- Offline.
-
- Forum Stats
- Member
- Level 03
- Blank Slate
Holy shitfuck Denvish just helped me! i love you denvish, i apologize sincerely for being a dick to people trying to help.



