playMaker

Author Topic: Rotating character  (Read 2624 times)

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Rotating character
« 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

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Rotating character
« Reply #1 on: June 08, 2021, 04:23:10 PM »
Hi.
How are you doing the movement?

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: Rotating character
« Reply #2 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.

Sketch

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Rotating character
« Reply #3 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.

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: Rotating character
« Reply #4 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!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Rotating character
« Reply #5 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.

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: Rotating character
« Reply #6 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!

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: Rotating character
« Reply #7 on: June 10, 2021, 04:26:30 PM »
Bump.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Rotating character
« Reply #8 on: June 10, 2021, 04:27:33 PM »
Hi,
The action Set Forward Velocity 2D is on the Ecosystem

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: Rotating character
« Reply #9 on: June 10, 2021, 04:44:41 PM »
I copy and pasted that in, but its not showing up for me. Any advice?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Rotating character
« Reply #10 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

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: Rotating character
« Reply #11 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. :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Rotating character
« Reply #12 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.

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: Rotating character
« Reply #13 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.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Rotating character
« Reply #14 on: June 11, 2021, 03:56:36 PM »
if its imported it should be in your action list