playMaker

Author Topic: Sprite Management  (Read 3639 times)

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Sprite Management
« on: May 11, 2013, 05:01:02 PM »
Hi,
I have animated sprites in one of my projects that exist in a 3D world.  Since the user can move the camera around, I need to display the sprite from the appropriate angle relative to the camera <i>and</i> direction they are moving in.

I've looked at several sprite management solutions but haven't seen any that would help with this specific goal.  Most of them are focused on atlas creation, animations and controlling the playback of those animations.  If anyone knows of a solution that will manage changing atlases depending on camera/sprite-movement relativity, that's exactly what I need and I'd appreciate it if you could share the knowledge.

For the time being I'm trying to create an FSM to manage this for me.  I thought to use the World To Screen Point action to get the position of the sprite, and set it's left or right atlas animation depending on what side of the screen it was on, while using the front or back atlases depending on if it were moving toward or away from the camera. 

Provided no one knows of a sprite solution that I can grab off the asset store or from the Unify wiki, can anyone suggest how I might tackle this in FSM form? 

Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Sprite Management
« Reply #1 on: May 12, 2013, 04:16:47 AM »
Hi,

 what you are looking for is called "BillBoard", I am curious, what framework are you using? I'll double check, cause chances are they provide such facility already.

 get a component from the Unity Wiki:

http://wiki.unity3d.com/index.php?title=CameraFacingBillboard

bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Sprite Management
« Reply #2 on: May 12, 2013, 04:21:35 AM »
Hi,

 actually... I did a billboard playmaker action for this already :)

http://hutonggames.com/playmakerforum/index.php?topic=2417.0

bye,

 Jean

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: Sprite Management
« Reply #3 on: May 12, 2013, 11:35:32 AM »
Hi Jean!

Actually that's not what I mean.  I use the billboard script from the unify wiki already, or just have my plane use a "look at" action.

My problem is that since the camera in the 3D scene can move "around" the sprites, the sprite needs to switch which atlas it's using to display different "sides" of the character.  Here's an example:


Think of strafing around an enemy in Doom.

Thanks for your reply!


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Sprite Management
« Reply #4 on: May 13, 2013, 04:45:52 AM »
hi,

 ok I see. then you'll need quite some work in there.

-- you will need to have your player as an invisible gameObject so you know exactly where it should be oriented.

-- then your sprite attached to that gameObject

-- and a fsm that check the angle of the root player against the camera and switch in between

for the fsm, I would simply use "get Angle to Target" and then use a compare action to switch when appropriate.

you could also use my signed angle action, this might be easier than with GetAngle action.

http://hutonggames.com/playmakerforum/index.php?topic=1027.msg4256#msg4256

Bye,

 Jean