playMaker

Author Topic: Making object to play correct animation based of headed direction [SOLVED]  (Read 1707 times)

Just

  • Playmaker Newbie
  • *
  • Posts: 41
I have game where you guide movement of object by clicking mouse. For animations I'm currently using Float Compare for MouseX and MouseY variables, however it's not working 100% correctly. Is there a way I could reliably refer game to play correct animation based of direction object is heading?
« Last Edit: March 28, 2019, 06:10:39 AM by Just »

ch1ky3n

  • Full Member
  • ***
  • Posts: 208
Re: Making object to play correct animation based of headed direction
« Reply #1 on: March 20, 2019, 11:24:55 PM »
Your movements, is it

4-ways movement
8 ways Movement
360 degree ?


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Making object to play correct animation based of headed direction
« Reply #2 on: March 21, 2019, 02:18:37 AM »
Hi.
Is it for a 2d or 3d game?

Could you show a video or some images of what you have now?

Just

  • Playmaker Newbie
  • *
  • Posts: 41
Re: Making object to play correct animation based of headed direction
« Reply #3 on: March 21, 2019, 04:05:25 PM »
It's 2D, 8-ways movement, I use 4 sprite animations (up, down and sideways), fixed camera (camera doesn't move).

With keyboard, it's no-brainer (Key Down -> Play animation). With mouse, it should recognize position object is heading to and play correct moving animation corresponding that.

Edit: Here's screenshot, you press anywhere on screen and character moves to that spot.
« Last Edit: March 21, 2019, 04:33:29 PM by Just »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Making object to play correct animation based of headed direction
« Reply #4 on: March 21, 2019, 06:55:06 PM »
Hi.
Maybe get the angle to the target position?

Then with some float compares you can set the correct animation.

Just

  • Playmaker Newbie
  • *
  • Posts: 41
Re: Making object to play correct animation based of headed direction
« Reply #5 on: March 28, 2019, 06:09:41 AM »
So, a little update with my progress. I couldn't get Get Angle to Target to work properly (I'm not sure if it's more suited for 3D-environment) but I made workaround.

Problem for Float Compare of Mouse X/Y is that it's based of where in screen you're pressing rather than where moveable object is. For example when you press somewhere upper screen, and object is border of upper side, it still play going up animation even if it's actually heading down.

My workaround that works 98% of times is that it won't play animation if transformation of X or Y is small. That way, it won't do moonwalking and it's something that no one probably won't notice.

I mark this solved, but feel free to comment if anyone has some input.