Switching angles of diagonal character loops?

Started by blaholtzen, Sat 25/11/2023 21:06:31

Previous topic - Next topic

blaholtzen

I'm putting an isometric over-world in my game and my current solution for making sure my character is using the correct loop while going in the eight directions is to just have a crude network of grid-like paths for him to ride his bike on.




However ideally I'd let him roam free. Or at least a free-er.
My issue being that diagonal movement loops for characters are based around being 45 degrees, which would work fine if it was entirely top down, and sorta makes sense in terms of dividing up angles evenly, but makes it hard to properly convey a viewing angle that's closer to the ground.

Even moving along thin paths like he is now it still looks uneven whenever he turns around.

I'm assuming what happens is something like: the game checks if the angle that the character is traveling in is closer to whichever angle is the "center" for each loop angle, like, is the angle closer to 90 or 45, and if so use that loop etc.

Basically what I'm looking to achieve is changing the "center" of when a character uses the diagonal loop from 45 degrees to something like 26,5.



I have seen some isometric control modules and such but I'd prefer to keep the existing clicking and path finding behavior if I can since I'm trying to keep the game effectively mouse-only, and from what I've noticed, in my case its really only the angle of the diagonals for the character that causes me any issues by ruining the illusion.

Thanks :)


eri0o

Random shot in the dark, have you tried to make the Y move speed half the X move speed and see if this changes anything? Probably not for the angle but I am trying to think what does your squished circle would have to map for this angle change you say.

blaholtzen

I do have it set up that way currently yeah, it does make the speed make sense for the perspective but that's about it.

I made a new image that better shows what I'm looking to achieve with the angles rather than the reason why:



Basically if a character is traveling at any angle in one of those green zones its going to use the respective loop for that diagonal. I want to change those angles so it better reflects the perspective. So for example, the up-right loop would appear if the character is traveling at any angle between 13.25 and 53 degrees, instead of the current range which i think comes out to between 22.5 and 67.5 degrees.

blaholtzen

#3
The main "issue" in context looks like this:



Where if the character travels at an angle even slightly more horizontal than ~26 degrees it switches to the horizontal loop, when for my uses I'd want this to still be using the diagonal loops.


I assume I would need to set up some custom walking animation thing where I calculate the angles and assign the loop manually but I do not know how to do trigonometry and I know even less how to code it, lmao
Like I understand what needs to happen in rough terms but not how to put it together in code.

eri0o

Hey @blaholtzen , can you backup your game and try this ⚠🚨EXPERIMENTAL AGS Editor🚨⚠ ?

It has an additional Game.SetDirectionRatio(float ratio), and then in your game's global script, in the game_start, use Game.SetDirectionRatio(2.0); and see if this helps or not. Also please try a few values around 2.0 to see if it helps.

This uses a experimental api made by @Alan v.Drake , perhaps it can be changed later/adapted, but curious if it would solve your problem.

Crimson Wizard

#5
There have been a conversation about similar problem here, with a script suggested by @Khris:
https://www.adventuregamestudio.co.uk/forums/beginners-technical-questions/more-than-8-character-facing-directions/msg636657457/#msg636657457

I think this may be more or less the same thing as in Alan's experimental feature.

EDIT: I was planning to write a feature ticket about this, but kept forgetting, so here it is:
https://github.com/adventuregamestudio/ags/issues/2243

blaholtzen

@eri0o

Oh wow! Yeah DirectionRatio(2.0) makes it look completely correct! Its hard to tell what exact angles its changing at but it seems basically dead on with the graph haha.

So yeah this gets a big thumbs up from me!


Snarky

Really nice diagrams, @blaholtzen! And I'm happy that it looks like (barring unexpected complications) this feature is making it into the main engine branch.

eri0o


Crimson Wizard

UPDATE
This feature implementation is discussed here in this topic:
https://www.adventuregamestudio.co.uk/forums/editor-development/feature-request-character-direction-ratio/

There's already a test build available (based in AGS 4.0), but we need some kind of a test game which would prove that the functionality serves the purpose.

SMF spam blocked by CleanTalk