A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [F8] Help with NPC random movement and interaction

  1. #1
    Junior Member
    Join Date
    Sep 2007
    Posts
    2

    Exclamation [F8] Help with NPC random movement and interaction

    Hello everyone,
    I am trying to work out a drag and drop NPC with random movement that you can interact with. I finally found some script that makes him move like I would want him to(classic RPG) but can't figure out how to get him to change the way he faces with the direction he is moving. I have left right, up, down, resting clips and then speaking that would eventually show on a mouse click. Can someone please help or direct me the right way??? This would also need an invisible wall in the clip so he doesn't randomly move outside of his area.


    I have been combing the net but can't seem to find anyone that is doing anything like this. Please look over my file and let me know if this Is possible? Everything is inside and neatly situated. Thanks in advance =)
    Attached Files Attached Files

  2. #2
    Senior Member PRadvan's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    261
    Inside NPCdrop, give your character movie clip (which is called chrono in the library) a name in the properties box "chrono_mc"

    then change the following code:

    PHP Code:
    if (randommove == 1) {
            
    this._x += 20;
            
    chrono_mc.gotoAndStop("right");
        } else if (
    randommove == 2) {
            
    this._x -= 20;
            
    chrono_mc.gotoAndStop("left");
        } else if (
    randommove == 3) {
            
    this._y += 20;
            
    chrono_mc.gotoAndStop("down");
        } else if (
    randommove == 4) {
            
    this._y -= 20;
            
    chrono_mc.gotoAndStop("up");
        } else {
            
    chrono_mc.gotoAndStop("rest");
        } 

  3. #3
    Junior Member
    Join Date
    Sep 2007
    Posts
    2
    Thanks a million PRadvan.. looks and works beautifully..

    I had to take off all the _root.wall.hitTest code under your modifications because they were giving me some errors. I will have to try and figure out that invisible wall part next so he doesn't keep walking off the screen constantly!

    If anyone has any ideas let me know.. either way If I get it working completely I will post the new file and hopefully others can get some use out of it as well. Thanks again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center