Randomly wandering NPC overlap issues - SOLVED

Started by Akril15, Sat 15/07/2023 19:54:43

Previous topic - Next topic

Akril15

I've got a couple of rooms set up to make several NPCs wander through them along one of several paths on a single large walkable area (I hesitate to post it at the moment, since it's pretty messy). My script works good, except for what happens if the player character (who is using the same walkable area) walks into one of them, or vice versa.

If the NPCs are solid, they will stop moving when the player character collides with them, but if they're not solid, I encounter a number of issues with the characters overlapping incorrectly (often making it look like one character is walking on top of the other), and unsurprisingly, the NPCs will often walk through the player character like they're ghosts. I've tried making the player character stop when overlapping with another character, but the "walking over characters" issue still comes up. I've tried changing the player's baseline when colliding with an NPC, but that doesn't seem to work either.

Is there another technique I might consider?

Snarky

What do you actually want to happen?

Akril15

Quote from: Snarky on Sat 15/07/2023 20:22:42What do you actually want to happen?
I just want to keep the characters from overlapping where one character is "floating" in front of the other. I've tried adjusting the NPCs' Z axes (the player character's is -25), but I still end up encountering this problem whenever I make the player character walk into one of the NPCs.

Crimson Wizard

Quote from: Akril15 on Sun 16/07/2023 03:22:42I just want to keep the characters from overlapping where one character is "floating" in front of the other. I've tried adjusting the NPCs' Z axes (the player character's is -25), but I still end up encountering this problem whenever I make the player character walk into one of the NPCs.

If you're refering to the "Character.z" property, that is a graphical offset, the property you need is called Baseline.
https://adventuregamestudio.github.io/ags-manual/Character.html#characterbaseline
https://adventuregamestudio.github.io/ags-manual/Character.html#characterz

Akril15

I actually was adjusting the baseline as well, and I think I may have found a solution. I was using IsCollidingWithCharacter when I should have been using AreThingsOverlapping. This is what I've got in rep_exec right now:

Code: ags
if (AreThingsOverlapping(SERM1, EGO)) {
if (cSerM1.y<cEgo.y) cEgo.Baseline=600; //if npc is behind player
else cEgo.Baseline=cSerM1.y-20; //if npc is in front of player
}

///other character's scripts here

else cEgo.Baseline=0;

This needs a bit of tweaking as there's still a tiny bit of incorrect overlapping going on. The players also phase through each other at times, but it's not quite as obvious.

SMF spam blocked by CleanTalk