ForumsProgramming ForumNpc Programming

15 5774
SkyderStudios
offline
SkyderStudios
7 posts
Nomad

I've been working on this game for a while now, and I've gotten most things to work. I have the health bar working, the game over screen working, and have it so it's fairly easy to move in the levels, but I'm having some trouble with my enemies and attacking them.
http://frost-skyder.deviantart.com/art/Termination-116498169?
I was wondering if anyone could help me fix a few issues. That's not the entire game (that would be horribly boring), but some of my script I've been testing, so far, some issues have come up.

First Issue:My character won't follow through on his attack move. I know it only recognizes when the Space bar is down, but I want to find a way so the animation finishes, even if the button is not being pressed.
http://i248.photobucket.com/albums/gg196/Frost_Skyder/SkyderCode1.jpg

[quote="Main Scrip on Main Character Movie Clip"]
//Main Character's Movement
onClipEvent(enterFrame){

if(_root.Health<=0){
_root.gotoAndPlay("GameOver&quot;}

if(Key.isDown(Key.RIGHT)){
this.gotoAndStop("Run Right&quot;
this._xscale =100;
}else if(Key.isDown(Key.LEFT)){
this.gotoAndStop("Run Right&quot;
this._xscale =-100;
}else if(Key.isDown(Key.SPACE)){
this.gotoAndStop("Attack 1&quot;
}else if(Key.isDown(Key.DOWN)){
this.gotoAndStop("Duck&quot;
}else{
this.gotoAndStop("Idle 1&quot}
}
[/quote]

[quote="Script on Attack Move"]
//Main Character's Code on Attack Movement
onClipEvent (enterFrame) {
if(_root.Skyder.hitTest(_root.Npc1)){
_root.Npc1.gotoAndPlay("Npc1 Die&quot;}[/quote]
That's what I've got for now, and it seems to work fairly well. The Attack move is what kills my npc, I just wish the animation would follow through.

Second Issue:My enemy just sits there....I don't know any script for programming him to run up to my character when he's a determined pixels apart. I've heard of "A*" script, but don't understand it at all, or know how to use it.

[quote="Npc Movement (Keeps him with the background)"]
//Npc1's Movement
onClipEvent (enterFrame) {
if(Key.isDown(Key.RIGHT)){
this._x-=15
_xscale =60;
}else if(Key.isDown(Key.LEFT)){
this._x+=15
_xscale =60;}

}[/quote]
[quote="The Enemy's Attack"]
//Npc1's Attack Movement
onClipEvent (enterFrame) {
if(_root.Skyder.hitTest(_root.Npc1)){
_root.Health -=1;}
}[/quote]
That's about where all my problems lie. All my other script is working just dandy. If anyone has any suggestions, or some advice, I'd be thrilled to hear it. I've been stuck on these problems for a while now.

  • 15 Replies
Showing 16-15 of 15