#Character walkto and directions

1 messages · Page 1 of 1 (latest)

sick ermine
#

Characters have only one walkto point and if a character can move and most importantly turn around, the walkto point ends up behind them.

What would be the best way to solve this (unless PQ offers direction dependent walkto points)?

I'm currently adding to my two playable characters a component called WalkToFlipper where you can specify a walkto point for every face direction and it changes it in the Update function, but I don't know if there's a better, cleaner way.

sick ermine
#

also: is there a way to avoid using diagonal directions altogether? I only have the four cardinal ones but if the character is facing downright, I want to have a walkto point depending on the sprite, and sometimes it uses right instead of down

frank pendant
#

Great question... I've thought about how to better do that a few times but none of my solutions were that elegant though so haven't added anything to PQ.

On my own projects in the past I've just flipped the walk-to in the room's update function, similar to your WalkToFlipper component. I ws just doing it on a case-by-case basis. And based on the player's position relative to the character, not the direction the target character's facing.

eg. this ugly bit of code in a room's Update function 😉

    if ( Mathf.Sign( Plr.Position.x - C.Reporter.Position.x ) !=  Mathf.Sign(C.Reporter.WalkToPoint.x) )
        C.Reporter.WalkToPoint = C.Reporter.WalkToPoint.WithX(-C.Reporter.WalkToPoint.x);
#

But since I started doing this more often, I added some "WalkNear()" functions, and a "WalkNearClicked" as a PowerQuest extension that I've been using more often recently.

And that solves your issue, but also the thing where you're standing close enough to talk to someone, and don't really need to walk exactly to a point, just to talk to them. Basically just moves the character into a range where it's not awkward to talk, but only if necessary.

#

That code's mixed up with a bunch of other extensions but I can split it out and share it if you like. I'm not 100% convinced it's the best way to do it yet though either 😉