Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: hoyoyo80 on February 02, 2020, 08:34:30 AM

Title: learning top down shooter : 2d sprite facing right analogue direction
Post by: hoyoyo80 on February 02, 2020, 08:34:30 AM
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
Title: Re: learning top down shooter : 2d sprite facing right analogue direction
Post by: hoyoyo80 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

Title: Re: learning top down shooter : 2d sprite facing right analogue direction
Post by: jeanfabre 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
Title: Re: learning top down shooter : 2d sprite facing right analogue direction
Post by: hoyoyo80 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:)
Title: Re: learning top down shooter : 2d sprite facing right analogue direction
Post by: jeanfabre 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