Centering the character baseline

Started by Oz, Sat 31/07/2004 12:25:20

Previous topic - Next topic

Oz

I would like to permanently move the character baseline from 0 (the character's feet) to center (the character's waist). I've been toying around with SetCharacterBaseline without success. What would the correct SetCharacterBaseline command be? The char is 16 pixels tall. The reason I want to move the baseline is that I'm working on a top-down adventure game. I want the collision detection for the walkable areas to be calculated from the character's center point instead of its feet.

Thanks!
Diversity is divine!

Fabiano

hm.. i guess if u use setcharacterbaseline (char, character[char].y-16); in the repeated execute would work
Yeah, yeah, It happens. A lot.

Oz

Hmmm. No luck there. It doesn't seem to move the baseline at all. I wish there was a debug feature that would let you view baselines at runtime.
Diversity is divine!

Goot

I don't think walkable areas test for the baseline. Just the x,y coordinate. I had the same problem when I tried to do a top view. I made an invisible player character and another character (the one with the actual character's picture) was constantly put below it so the invisible character was in the middle of the other one.

In repeatedly execute:

character[CHAR].x=character[INVISIBLEGUY].x;
character[CHAR].y=character[INVISIBLEGUY].y+half the character's hight

The invisible guy's x and y coordinates (middle of the other guy) will trigger hotstops and stuff.

Ashen_Away

SetCharacterBaseline (EGO, character[EGO].y-8);

in the repeatedly execute should work, but since you say it doesn't, you could try SetCharacterViewOffset instead, e.g.:

SetCharacterViewOffset (EGO, 1, 0, character[EGO].y-8);

This should only need to be run once (at game start), unless you want to change the character view (like if they change clothes). However, you'll need to have a similar line for every character in the game, e.g.:

function game_start() {
  SetCharacterViewOffset (EGO, 1, 0, character[EGO].y-8);
  SetCharacterViewOffset (NPC, 3, 0, character[NPC].y-8);
  SetCharacterViewOffset (ENEMY, 4, 0, character[ENEMY].y-8);
  SetCharacterViewOffset (BOB, 2, 0, character[BOB].y-8);
  etc...
}

Hope this helps.

Oz

Quote from: Goot on Sat 31/07/2004 18:39:26
I don't think walkable areas test for the baseline.

Does anyone know if this is the case? It seems that the player will move his feet to the top and bottom of the walkable area before stopping, indicating that the baseline (0) is used for detection.

Ashen_Away,

Thanks, I'll try toying around with SetCharacterViewOffset.
Diversity is divine!

Snarky

#6
There have already been several other threads about this recently. Basically, it cannot currently been done: The characters' "hotspot" (the point used as their position for purposes of walkable areas and walk-to commands) is fixed to the bottom center. However, it's on CJ's to-do list (and may be in the latest beta?), and there are workarounds.

If you just need to change the walk-to point, you can use something like:

Code: ags
if (GetCursorMode()==MODE_WALK){
Ã,  Ã,  Ã,  Ã,  MoveCharacter(GUYBRUSH, mouse.x, mouse.y+29);
}


The best workaround for the walkable areas is probably to manually offset them by the appropriate number of pixels. This is very easy to do if you're defining your walkable areas in a painting application.

Oz

Snarky,

Thanks for sorting that out. The problem is that producing a top-down game requires you to be able to center the character hotspot for proper alignment of the character in walkable areas. I'll try your workaround and see what I come up with!
Diversity is divine!

Proskrito

#8
in the newest versions of ags, there is a character[CHARID].z variable, you could try to modify it to set the middle point for walkabe areas higher.

EDIT: i have made a function for you, try it and see if thats what you wanted:
Code: ags

function CenterCharacterBaseline(int charid){
int charsprite = GetGameParameter(GP_FRAMEIMAGE,character[charid].view+1, character[charid].loop, character[charid].frame);
int spriteheight= GetGameParameter(GP_SPRITEHEIGHT, charsprite ,0,0);
character[charid].z=-(spriteheight/2);
}

SMF spam blocked by CleanTalk