Jump to content


Photo

Movement problem


  • Please log in to reply
2 replies to this topic

#1 111Studio

111Studio

    GMC Member

  • GMC Member
  • 258 posts
  • Version:GM:Studio

Posted 26 April 2011 - 10:21 PM

Okay, so I think I'm misunderstanding how to use the position_meeting function. Here is my code:

if (move == 1){
    //Grab the correct x,y offset for the square in the direction of requested travel
    var checkX,checkY,dir;
    dir = direction/90;
    checkX = scrGetControl(dir,arrayX);
    checkY = scrGetControl(dir,arrayY);
    
    //Record instance id of instance located at the x,y offset.
    collideInst = position_meeting(x+checkX,y+checkY,all);

    //Assume movement until told otherwise
    move = 2;
    
    //As long as the instance id variable is not "noone" run the switch statement
    if (collideInst!=noone){
        //Check for the object_index
        switch (collideInst.object_index){

            //When it is objWall, disallow movement
            case objWall: move = 0; break;

            //When it is objFinish, execute next room function
            case objFinish: scrNextRoom(); break;

            //When it is objTeleport, teleport to target location
            case objTeleport: if (use == 1){scrTeleportTo(collideInst);} break;

            //When it is none of the above, throw error.
            default: show_message("Error: Case not accounted for"); break;
        }
    }
}

It always throws the error message. I can't figure out why it's not working properly.

An extra pair of eyes would be greatly appreciated.

111Studio
  • 0

#2 Mnementh

Mnementh

    15151

  • Retired Staff
  • 6261 posts
  • Version:GM:Studio

Posted 27 April 2011 - 12:44 AM

It would be good to know what the actual value of collideInst.object_index is at that point in time.
  • 0

#3 111Studio

111Studio

    GMC Member

  • GMC Member
  • 258 posts
  • Version:GM:Studio

Posted 27 April 2011 - 04:02 AM

Solved. The issue was a matter of using the wrong function. "position_meeting" needed to be "instance_position." Kinda vague in the manual.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users