-
Mя.Åŋdëŗ§ǿ
[Problem]: Random Walking Person.
This is really tricky for me.
I am trying to create a radom walking person, animale, and so on.
Just a general walking script that i will use over and over for every towns person and animale I add in my game.
What I need:
is the basic collision so it doesnt walk past an object. Collision with the player so it doesnt walk through to you. then collision with player and if key is down enter, the person or animal faces you and says a msg. (for the msg a trace would be fine, i have my own code for the msg to show up.) then when you press enter (on the msg so not on the random towns persons script) it will make him re walk again.the way to do that could have all the codes with in an if (talkingtoperson != true){
blah blah
if (colossion and enter){
talkingtoperson = true;
}
blah blah
}
then on the msg part when you press enter your doen reading it will jsut turn that flasg false (i know how to do that part of course).
now I have been working on it. all i have goten done is the random walking.
I am having problems when I added the colission.
here take a look at my code, maybe some one could help? thanks
Code:
onClipEvent (load) {
var randomnum:Number;
var getnewyflag:Boolean;
var getnewxflag:Boolean;
var getnewy:Number;
var getnewx:Number;
getnewyflag = true;
getnewxflag = true;
}
onClipEvent (enterFrame) {
if (getnewxflag == true) {
if (shutthisoff != true){
ranran2 = Math.floor(Math.random()*(8-(0+1)))+0;
}else{
ranran2 = ranran2val;
}
if (ranran2>=1 && ranran2<=4) {
getnewxran = Math.floor(Math.random()*(100-(5+1)))+5;
} else {
if (ranran2>=5 && ranran2<=8) {
getnewxran = Math.floor(Math.random()*(-100-(-5+1)))-5;
}
}
if (ranran2 == 0) {
getnewxran = 0;
}
getnewx = this._x+getnewxran;
}
if (getnewyflag == true) {
if (shutthisoff2 != true){
ranran = Math.floor(Math.random()*(8-(0+1)))+0;
}else{
ranran = ranranval;
}
if (ranran>=1 && ranran<=4) {
getnewyran = Math.floor(Math.random()*(-100-(5+1)))+5;
} else {
if (ranran>=5 && ranran<=8) {
getnewyran = Math.floor(Math.random()*(-100-(-5+1)))-5;
}
}
if (ranran == 0) {
getnewyran = 0;
}
getnewy = this._y+getnewyran;
}
if (this._y != getnewy) {
shutthisoff2 = false;
getnewyflag = false;
if (this.hitTest(_root.walln)) {
this._y+1;
getnewy = this._y;
shutthisoff2 = true;
ranranval = 5;
}
if (this.hitTest(_root.walls)) {
this._y+1;
getnewy = this._y;
ranranval = 1;
shutthisoff2 = true;
}
if (getnewy<this._y) {
this._y--;
}
if (getnewy>this._y) {
this._y++;
}
} else {
if (this._x != getnewx) {
shutthisoff = false;
getnewxflag = false;
if (this.hitTest(_root.walle)) {
this._x+1;
getnewx = this._x;
ranran2val = 1;
shutthisoff =true;
}
if (this.hitTest(_root.wallw)) {
this._x-1;
getnewx = this._x;
ranran2val = 5;
shutthisoff =true;
}
if (getnewx>this._x) {
this._x++;
}
if (getnewx<this._x) {
this._x--;
}
}
if (this._y == getnewy && this._x == getnewx) {
getnewyflag = true;
getnewxflag = true;
}
}
}
BTW: this is on the movie clip of the walking kitten. (i would like the code to be on the mc's action script panel, not frame.) thanks.
I Use Flash 8
Help is my last name, Freeload is my first :P
إŦ№إ Mя. Åŋdëŗ§ǿņ
-
Patron Saint of Beatings
What version of Flash are you using?
-
Mя.Åŋdëŗ§ǿ
Flash 8 Of Course
I Use Flash 8
Help is my last name, Freeload is my first :P
إŦ№إ Mя. Åŋdëŗ§ǿņ
-
Mя.Åŋdëŗ§ǿ
any help with just the colission part then?
I Use Flash 8
Help is my last name, Freeload is my first :P
إŦ№إ Mя. Åŋdëŗ§ǿņ
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|