playMaker

Author Topic: Newbie question on sprite rotation?  (Read 2757 times)

dharry

  • Playmaker Newbie
  • *
  • Posts: 11
Newbie question on sprite rotation?
« on: July 16, 2015, 02:25:31 AM »
Hi All, new to Playmaker so please bare with me :)

I am making a 2d top down game. I have a sprite with 4 animations (using animator), 1 for left, 1 for right, 1 for up and 1 for down.

I can't seem to work out how to get the right animation to display, or the right orientation of the sprite depending on which direction the sprite is moving...

Can anyone point me to an example project or offer any help?

Thanks
Dean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: Newbie question on sprite rotation?
« Reply #1 on: July 16, 2015, 08:58:23 AM »
Hi,

 you could expose 4 boolean animator properties and then based on the user input, you trigger each animator property accordingly.

make sure you get the Mecanim package for PlayMaker on the wiki or Ecosystem to be able to control animator properties.


Bye,

 Jean

dharry

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Newbie question on sprite rotation?
« Reply #2 on: July 16, 2015, 05:06:55 PM »
Thanks Jean,

My problem is not my character, I have that working perfectly... my problem is my game enemies, they follow a pre-defined path so they have no input to be able to watch for.

Dean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: Newbie question on sprite rotation?
« Reply #3 on: July 17, 2015, 01:57:31 AM »
Hi,

 then use the velocity and get the angle the velocity makes from the forward axis of your gameobject, this will be your direction of movement, expressed in degrees, so then if it's between -45 and 45 it's forward, 45 to 135 it's right, etc etc.

 I know as well that Unity has a sample showing a mecanim setup where it does that automatically by just feeding it with the angle.

https://www.assetstore.unity3d.com/en/#!/content/5328

check the minebot animator setup, it's complex but is very close to what you want.

also check this thread, it has a mecanim system using direction, it's very close to what you can do with your enemy.

http://hutonggames.com/playmakerforum/index.php?topic=5161.msg24546#msg24546


Bye,

 Jean