Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - celadonk

#1
Interesting! I would have never thought of using greater than/less than as a math expression to determine the animation. Thank you very much for the suggestion! It does seem like this still creates a blocking walk, so you can't turn mid movement.
#2
Ah! Smart! Guess I missed that. Thank you so much for the suggestion!
#3
Alright... here's what I came up with. It's probably not a super efficient way of going about things. I have very very little programming background, so hopefully this isn't TOO scary to all the coders out there :D

Code: ags
function DetermineCharacterAngle(Character *c)
{
    if (c.GetProperty("TargetX") < c.x && c.GetProperty("TargetY") > c.y) { //down left
        c.SetProperty("CharacterAnim", 1);
  }
    else if (c.GetProperty("TargetX") > c.x && c.GetProperty("TargetY") > c.y) { //down right
        c.SetProperty("CharacterAnim", 0);
  }
    else if (c.GetProperty("TargetX") < c.x && c.GetProperty("TargetY") < c.y) { //up left
        c.SetProperty("CharacterAnim", 3);
  }
    else if (c.GetProperty("TargetX") > c.x && c.GetProperty("TargetY") < c.y) { //up right
        c.SetProperty("CharacterAnim", 2);
  }
  //orthogonal direction handling
  else if (c.GetProperty("TargetX") == c.x && c.GetProperty("TargetY") > c.y) { //down
    if (c.GetProperty("CharacterAnim") == 0 || c.GetProperty("CharacterAnim") == 2) {
      c.SetProperty("CharacterAnim", 0);
    }
    else {
      c.SetProperty("CharacterAnim", 1);
    }
  }
  else if (c.GetProperty("TargetX") == c.x && c.GetProperty("TargetY") < c.y) { //up
    if (c.GetProperty("CharacterAnim") == 0 || c.GetProperty("CharacterAnim") == 2) {
      c.SetProperty("CharacterAnim", 2);
    }
    else {
      c.SetProperty("CharacterAnim", 3);
    }
  }
  else if (c.GetProperty("TargetX") < c.x && c.GetProperty("TargetY") == c.y) { //left
    if (c.GetProperty("CharacterAnim") == 0 || c.GetProperty("CharacterAnim") == 1) {
      c.SetProperty("CharacterAnim", 1);
    }
    else {
      c.SetProperty("CharacterAnim", 3);
    }
  }
  else if (c.GetProperty("TargetX") > c.x && c.GetProperty("TargetY") == c.y) { //right
    if (c.GetProperty("CharacterAnim") == 0 || c.GetProperty("CharacterAnim") == 1) {
      c.SetProperty("CharacterAnim", 0);
    }
    else {
      c.SetProperty("CharacterAnim", 2);
    }
  }
}

function MovePlayerToMouse()
{
  cRoger.SetProperty("TargetX", mouse.x);
  cRoger.SetProperty("TargetY", mouse.y);
  DetermineCharacterAngle(cRoger);
  cRoger.Animate(cRoger.GetProperty("CharacterAnim"), 1, eRepeat, eNoBlock);
  cRoger.Move(cRoger.GetProperty("TargetX"), cRoger.GetProperty("TargetY"));
  while (cRoger.Moving) {
    Wait(1);
  }
  cRoger.ChangeView(cRoger.View);
}

DetermineCharacterAngle() uses the character's current coordinates and a set of target coordinates (two custom properties-- just in case two or more characters are moving different directions at once) to determine which animation to use. (I wasn't able to figure out the arctan thing, but I appreciated the suggestion!) The orthogonal bits have an extra thing to preserve the character's facing on the other axis (for example, a character who moves up and then straight left will use the up/left animation).

MovePlayerToMouse() is called in the BASS template's TwoClickHandler script. It just overwrites the character's normal movement animation with the one determined by DetermineCharacterAngle(). I haven't tested NPC movement or keyboard movement yet (though I do have a script for the former), but I'm hopeful that it'll translate easy.

Hope this helps anyone who needs it!
#4
Absolutely! I'm going to be away from my computer for a couple days but when I get back, I'd love to post my code and help out others who need it.
#5
Hey everyone, I was able to find a solution! It's pretty clunky but it works and it seems like it'll be easily transferable to all characters.

What I ended up doing was setting up a helper script, as suggested, that determines the correct animation based on the angle, and then applied it in a function that handles the movement.

Thank you so much to all who offered solutions! Excited to have worked through my first AGS roadblock.
#6
Interesting! So it basically gives more weight to vertical or horizontal animations, as demonstrated in this diagram on the GitHub you linked:



Is it possible to rotate this diagram entirely? Like so:


If not, then no worries. (I think) I'm making good progress getting this to work in 3.6.1.
#7
Quote from: eri0o on Sun 28/04/2024 03:06:43What is the intended movement control scheme? Is it by mouse or keyboard button?
Both, which I've got set up. I'd also like characters that the player does not control to animate this way, too.

Quote from: Snarky on Sat 27/04/2024 23:10:18Then you would call that function when you make a character walk. For example, if you walk by clicking, you would probably call it in on_mouse_click().
I've put together a block of code, but it seems like putting anything in on_mouse_click() nullifies the movement-- I'm only getting the animation.

Is it possible to set this animation scheme up without connecting it to an input?
#8
Sorry, where/in what file do I do that calculation? Apologies, I just started with AGS yesterday. I've read through all the tutorials but am struggling a bit with going past default capabilities.
#9
Hello! I'm new to AGS and I'm excited to start making a game.

One of the things I'd love to do is Paper Mario-type diagonal movement. I've searched around here for a method of accomplishing this, and although I've found a couple of things that are close (isometric stuff), nothing is exactly right.

What I'd like is for characters to have free movement-- being able to walk to any point in any direction-- but for their animations to only be diagonal. In other words, instead of characters having four orthogonal facings (up, down, left, and right), they each have four DIAGONAL facings (ul/ur/dl/dr).

I was able to accomplish this in Godot before I decided that AGS may be better for what I want to do. Below is a GIF of how that looked.



I'd love to extend this behavior to all characters, too, which leads into a broader question of how does one do that? I know how to (generally) edit the behavior of one character but I'd like to make all characters move a certain way without having to manually do each one.

Thanks!

celadonk
SMF spam blocked by CleanTalk