Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: misterjuly on June 08, 2021, 03:22:19 PM

Title: Rotating character
Post by: misterjuly on June 08, 2021, 03:22:19 PM
Hello,

I have a character moving in four directions (like a top down Zelda), but I need my character to be able to change directions with the left and right keys. Currently, I have my character rotating when I hit the keys, but when I move, my character still goes the same direction it was going before. Like, if I rotate my character 90 degrees to the right, and I move up, I want my character to now move right, etc. Hope that makes sense. Thanks for your help!

John Bassi
Title: Re: Rotating character
Post by: djaydino on June 08, 2021, 04:23:10 PM
Hi.
How are you doing the movement?
Title: Re: Rotating character
Post by: misterjuly on June 08, 2021, 07:37:22 PM
I'm using get axis actions then set velocity 2d and then add force 2d. Then I use rotate action to rotate my character when I hit the arrow keys.
Title: Re: Rotating character
Post by: Sketch on June 09, 2021, 12:38:49 AM
I'm very new to playmaker so I might be talking nonsense, but could it work doing a direction check before the apply force, then using different states to apply the force in specific direction?
Use get position and save the z rotation value, save it to a variable. Then do a float compare saying if a value is xxx then apply force at either x/y.
Title: Re: Rotating character
Post by: misterjuly on June 09, 2021, 08:24:37 AM
Thanks for the advice. Sadly, my character can rotate every 5 degrees, so I'm not sure that this will work. Any other way to go about it? Thanks!
Title: Re: Rotating character
Post by: djaydino on June 09, 2021, 10:51:19 AM
Hi.
there is also a custom action called : Set Forward Velocity 2D

this will do the direction where its rotated toward.
Title: Re: Rotating character
Post by: misterjuly on June 09, 2021, 03:27:10 PM
Is the action called Set Rotation Velocity Direction 2d? I couldn't find something called exactly what you said and the action I have doesn't seem to be working right. Do I have the right action and if so what am I doing wrong? Thanks!
Title: Re: Rotating character
Post by: misterjuly on June 10, 2021, 04:26:30 PM
Bump.
Title: Re: Rotating character
Post by: djaydino on June 10, 2021, 04:27:33 PM
Hi,
The action Set Forward Velocity 2D is on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181)
Title: Re: Rotating character
Post by: misterjuly on June 10, 2021, 04:44:41 PM
I copy and pasted that in, but its not showing up for me. Any advice?
Title: Re: Rotating character
Post by: djaydino on June 10, 2021, 06:58:33 PM
Hi.
Hmm indeed...
Maybe i made this one myself a while ago, not sure.

you can get it from the attachment below
Title: Re: Rotating character
Post by: misterjuly on June 11, 2021, 10:08:51 AM
Thanks! This is a dumb question, but how do I take what you posted and turn it into an action; right now it's just code. Sorry for the silly question. :)
Title: Re: Rotating character
Post by: djaydino on June 11, 2021, 02:54:21 PM
Hi.
You should be able to double click it while your project is open and it should import.

Else do Assets/Import Package/Custom Package..

and search the package to import.
Title: Re: Rotating character
Post by: misterjuly on June 11, 2021, 03:41:24 PM
The code is imported, but how do I get it to be a playmaker action? Sorry I'm having such a hard time with such a simple thing.
Title: Re: Rotating character
Post by: djaydino on June 11, 2021, 03:56:36 PM
if its imported it should be in your action list
Title: Re: Rotating character
Post by: misterjuly on June 12, 2021, 12:19:33 AM
Thats a dumb dumb on my part. Thanks! I'll let you know how the action works later. Gotta go to bed now!
Title: Re: Rotating character
Post by: misterjuly on June 12, 2021, 09:10:38 AM
So, I'm trying it now, but it seems to only let the character face the one direction. How do I get it so I can rotate the character, and then move forward based on that rotation? Would I put the action with the rotating FSM, the rocket movement FSM, or something else? Thanks for all your help through this!

John Bassi
Title: Re: Rotating character
Post by: misterjuly on June 12, 2021, 09:13:27 AM
Also, would I remove my initial Set Velocity 2d action or keep that with it? Thanks again!
Title: Re: Rotating character
Post by: misterjuly on June 13, 2021, 07:36:11 AM
Bump!
Title: Re: Rotating character
Post by: djaydino on June 14, 2021, 04:24:47 PM
Hi.
Test it on a new scene.

Create a 2d object

add a fsm and place the forward velocity action in it

then while playing try changing the z direction

having other velocity will interfere with each other