Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started 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
-
Hi.
How are you doing the movement?
-
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.
-
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.
-
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!
-
Hi.
there is also a custom action called : Set Forward Velocity 2D
this will do the direction where its rotated toward.
-
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!
-
Bump.
-
Hi,
The action Set Forward Velocity 2D is on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181)
-
I copy and pasted that in, but its not showing up for me. Any advice?
-
Hi.
Hmm indeed...
Maybe i made this one myself a while ago, not sure.
you can get it from the attachment below
-
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. :)
-
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.
-
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.
-
if its imported it should be in your action list
-
Thats a dumb dumb on my part. Thanks! I'll let you know how the action works later. Gotta go to bed now!
-
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
-
Also, would I remove my initial Set Velocity 2d action or keep that with it? Thanks again!
-
Bump!
-
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