Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8571783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:51:28+00:00 2026-06-11T18:51:28+00:00

Basically, I’m trying to make a randomly generated character follow a series of waypoints

  • 0

Basically, I’m trying to make a randomly generated character follow a series of waypoints to get to where he needs to go without walking into walls etc on stage.

I’m doing this by passing an Array of Points from the Engine to the Character’s followPath function (this will be on a loop, but I haven’t gotten to that stage yet).

A part of this followPath function is to detect when the character is close enough to the waypoint and then move on to the next one. To do this, I’m trying to use Point.distance(p1,p2) to calculate the distance between the currently selected waypoint, and a point that represents the Character’s current position.

This is where I’m running into this problem. Trying to update the current (x,y) point position of the Character is proving difficult. For some reason, the Point.setTo function does not seem to exist, despite it being in documentation. As a result, I’m using

        currentPos.x = x;
        currentPos.y = y;
        //update current position point x and y

to try and do this, which is where my 1009 error is coming from.

Here is my full Character class so far:

package  {
import flash.display.MovieClip;
import flash.geom.Point;

public class Character extends MovieClip {

    public var charType:String;
    private var charList:Array = ["oldguy","cloudhead","tvhead","fatguy","speakerhead"];
    private var numChars:int = charList.length;
    private var wpIndex:int = 0;
    private var waypoint:Point;
    private var currentPos:Point;
    private var wpDist:Number;
    private var moveSpeed:Number = 5;

    //frame labels we will need: charType+["_walkingfront", "_walkingside", "_walkingback", "_touchon", "_touchonreaction", "_sitting"/"_idle", "_reaction1", "_reaction2", "_reaction3", "_reaction4"]

    public function Character() {
        trace("new character:");
        charType = charList[Math.floor(Math.random()*(numChars))];
        //chooses a random character type based on a random number from 0-'numchars'
        trace("char type: " + charType);

        gotoAndStop(charType+"_walkingfront");

        x = 600;
        y = 240;
    }

    public function followPath(path:Array):void {
        if(wpIndex > path.length){ //if the path has been finished
            gotoAndStop(charType+"_sitting"); //sit down
            return;//quit
        }

        waypoint = path[wpIndex];
        //choose the selected waypoint
        currentPos.x = x;
        currentPos.y = y;
        //update current position point x and y

        wpDist = Point.distance(currentPos,waypoint);
        //calculate distance

        if(wpDist < 3){ //if the character is close enough to the waypoint
            wpIndex++; //go to the next waypoint
            return; //stop for now
        }
        moveTo(waypoint);
    }

    public function moveTo(wp:Point):void {
        if(wp.x > currentPos.x){
            currentPos.x += moveSpeed;
        } else if(wp.x < currentPos.x){
            currentPos.x -= moveSpeed;
        }

        if(wp.y > currentPos.y){
            currentPos.y += moveSpeed;
        } else if(wp.y < currentPos.y){
            currentPos.y -= moveSpeed;
        }
    }

}

}

Can anybody explain to me why this is happening? It’s a roadblock that I haven’t been able to overcome at this stage.

I’m also curious if anybody can provide information as to why I can’t use the phantom Point.setTo method.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:51:29+00:00Added an answer on June 11, 2026 at 6:51 pm

    You’re trying to assign x and y properties of a Point object that doesn’t exist.

    You have to create your Point:

    currentPos = new Point ();
    

    and then assign x and y

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I need to get older version of a file in the repository without
Basically what I'm trying to do is make a very simple vertical bullet projectile
Basically, I'm trying to tap into the Soap pipeline in .NET 2.0 - I
Basically, I get the error: -[UIViewController donePress:]: unrecognized selector sent to instance 0x6a7f7c0 ***
Basically, what I'm trying to create is a page of div tags, each has
Basically I have converted a tab delimited txt file into a list containing a
Basically what I want to do is get a list of stores the employee
Basically I need to know how to make this work. I removed one of
Basically I'm trying to improve on the Ghosts in a Pacman game I'm making.
Basically my task is to make the counter on a micro controller board count

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.