playMaker

Author Topic: learning top down shooter : 2d sprite facing right analogue direction  (Read 1405 times)

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
Hi all,

After searching for days, regarding this matter, found similar problem but unclear solution so i beg for your help ;D

im taking some rest from main project and try to make 2d topdown shooter control(just the control, for now)

I manage to move the sprite with left analogue stick, in hierarchy the player has
empty  as parent,then the sprite as child. I manage to move the parent and now i want to make the sprite(child) to look the direction that the right analog is pointing.What action(s) should i look into?

Thanks

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
Re: learning top down shooter : 2d sprite facing right analogue direction
« Reply #1 on: February 05, 2020, 04:27:27 AM »
bump for my own topic:

I manage to get input for the right stick, but unable to get the right rotation for my sprite.

I use get axis vector(using XY plane,relative to Camera), convert vector3 to vector 2 and use smooth look at 2d. It doesnt really point to right analogue direction.

Help pls.Thanks


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: learning top down shooter : 2d sprite facing right analogue direction
« Reply #2 on: February 06, 2020, 08:01:32 AM »
Hi,

you need the action LookAtDirection for this, take the right joystick x and y value, make it a vector, that's your direction, then use LookAtDirection to look at that direction.

 have you tried that?


worse case, you can make a dummy as sibling of your player, and your move that dummy in self space based on the joystick value, which essentially is going to give you the target to use with a regular look at action.


Bye,

 Jean

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
Re: learning top down shooter : 2d sprite facing right analogue direction
« Reply #3 on: February 08, 2020, 05:16:41 AM »
using dummy sprite that set its position as right analogue work like charm ;D

But is there anyway to maintain its position after i release the right analogue stick? Any action to check this?

Thanks A Millions:)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: learning top down shooter : 2d sprite facing right analogue direction
« Reply #4 on: February 10, 2020, 10:37:15 AM »
Hi,

 yes, only update the position of the dummy if the joystick is down with a pointer or the mouse, and so as you release, it will stay at the last position.

Bye,

 Jean