Changing the Foot Point of a character (for walkale area collisions)

Started by ma2003, Sat 21/06/2008 15:39:00

Previous topic - Next topic

ma2003

Heres the question: Is it possible to move the feet-position hotspot (don't know what to call it) of the character, and move it towards the centre of the character sprite?

I've searched some info in other threads, and speak of using either player.baseline or player.z...

Baseline tends to not work at all(and I'm guessing its because its only used for walkbehinds, objects and characters).
While player.z does technically change the feet-position hotspot, it has to move the entire sprite in order to do it, I don't actually want my sprite to move at all, only the feet-position hotspot.

If anyone has any clues or any other ideas and approaches without moving the character sprite with the player.z, then I would appreciate it if you gave me some ideas.

Thanks alot.

Ishmael

If you want to move the absolute character location in relation to the sprite, naturally the sprite moves if the character co-ordiantes don't... I don't really see what else you'd be doing.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Khris

I assume this is for your top-down game you've showed in the other thread.
player.z is exactly what you need, I don't see the problem?

ma2003

Okay, the problem I'm having is:

Since my character has a crawling mode, the up view crawl looks like this:



Now, the reason why I need to change the centre pivot-position to a higher centre pivot position, is so my crawl-mode doesn't crawl over objects, a wall, or in this case (the above picture), the side of the tunnel. The reason why my character would constantly crawl over a wall or object, is because the centre pivot is set at the feet, not near the head. (this would apply to the up-direction-crawl-mode)

If I changed the centre pivot to a higher position, like the neck, then my crawl-mode character would stop at any type of wall once it reaches the neck because of where the walkable area stops allowing you to crawl.

Now, by using player.z....it technically solves my problem, but comes with an unwanted side effect. The sprite has to relocate itself into a lower position for the centre pivot to land itself where I would want it to go.

What makes it worse is that I have placed the player.z code along with the on_key_press command to tells my character to crouch. So in other words, the position of my sprites keep alternating from player.z = -15 to 0, each time I toggle the crouch mode.

view 3 = stand mode
view 8 = crawl mode

Code: ags

// This code is for UP CRAWL MODE
//==========This is allows character to go from standing mode to crawl mode===
if ((keycode == eKeycode_C) && (Region.GetAtRoomXY(cBob.x, cBob.y) == region[0]))
  if (cBob.View == 3) {        
    if (cBob.Loop == 3)  {             
        cBob.z=-15;
        cBob.TurnBeforeWalking = 0;
        RemoveWalkableArea(2);
        RestoreWalkableArea(4);
        SetWalkBehindBase(1, 200);
        cBob.ChangeView(8);
      }
      }
//==========This is allows character to go from crawl mode to standing mode===
  else if (cBob.View == 8) {
    if (cBob.Loop == 3)  { 
      cBob.z=0;
      RestoreWalkableArea(2);
      RemoveWalkableArea(4);
      SetWalkBehindBase(1, 148);
      cBob.ChangeView(3); 
}
}



Now I understand that just maybe AGS ain't built to do this sort of thing, unless theres something else that can be done, or maybe I'm missing something?

Thanks alot guys for replying.

Pumaman

The usual solution for this sort of thing is to adjust the position of the walkable area to compensate for this.

ma2003

Do you mean, as in:

Enabling and disabling walkable areas each time you press C in order to make the player stop as he approaches a wall?

If so, yeah I tried that, and yeah it worked. The problem was is that it would also stop oncoming left and right crawling modes too, especially when Trying to implement enabling and disabling walkable areas on both left and right crawl modes got kind of tricky, although its tricky-ness is just really me and my experience with scripting practices, I could assume.



Anyway, what I had originally done was use these walkable areas:

Walkable area 1 is my main walk-around area.

Walkable area  2 is my area that I disable each time he enters crawl mode, and enable again once he is not in crouch mode. This allows me to stop the player once he reaches a wall, in crawl mode. However, this also stops me from crawling left and right.

Walkable area 3 is always enabled, to use as bridge to get to Walkable area 4.

Walkable area 4 is turned on each time I enter crawl. This allows me to crawl through the tunnel. It remains disabled once the game starts.

Anyway, when walkable 2 is disabled while I'm in crawl mode, it stops me from crawling into a wall which is what I want. However, it also stops me from moving left and right also, at places that you would assume you could move.
Code: ags

//THIS CODE IS FOR UP CRAWL MODE
if ((keycode == 'C')
if (cBob.View == STANDING-MODE) {        
    if (cBob.Loop == FACEUP)  {
        RemoveWalkableArea(2);
        RestoreWalkableArea(4);
        cBob.ChangeView(CRAWL-MODE);
      }
      }
else if (cBob.View == CRAWL-MODE) {
    if (cBob.Loop == FACEUP)  {
      RestoreWalkableArea(2);
      RemoveWalkableArea(4);
      cBob.ChangeView(STANDING-MODE); 
}
}


The part for the down crawl mode would pretty much be exactly the same.

Code: ags

//=============RIGHT ARROW KEY CRAWL===========================

if ((keycode == 'C')
  if (cBob.View == STANDING-MODE) {        
    if (cBob.Loop == FACERIGHT)  {
        RestoreWalkableArea(2);
        RestoreWalkableArea(4);
        cBob.ChangeView(CRAWL-MODE);
      }
      }
  else if (cBob.View == CRAWL-MODE) {
    if (cBob.Loop == FACERIGHT)  {
        RestoreWalkableArea(4);
        cBob.ChangeView(STANDING-MODE); 
}
}


But for this last one, on both right and left crawl modes, I place RestoreWalkableArea(2); so I can allow my character to move LEFT AND RIGHT while near the wall, both when I press C, or move left while in crawl mode.

However, it doesn't work. It might be a little confusing. Someone might be able to point out my faults. Theres most likely something I missed typing out.

Thanks.

SMF spam blocked by CleanTalk