# playMaker

### Author Topic: Invert Horizontal Axis.  (Read 917 times)

#### bunnyrick

• Playmaker Newbie
• Posts: 12
##### Invert Horizontal Axis.
« on: April 02, 2019, 09:38:24 AM »
Hi!

I'm just starting out with Playmaker and i need some help inverting the Horizontal Axis when the player Y Rotation is bigger than 90 or -90, meaning that when i press A he will move Right and D Left.

Note that i'm rotating the player to the mouse using Mouse Pick and Smooth Look At, so when my character is facing back, the horizontal control inverses. I'm also rotating the camera with Q and E and the same happens. That's why i'm trying to reverse it like i wrote above.  Is it possible to do, or is there a better way to fix it?
« Last Edit: April 02, 2019, 01:49:29 PM by strangerick »

#### Athin

• Full Member
• Posts: 129
##### Re: Invert Horizontal Axis.
« Reply #1 on: April 02, 2019, 09:53:18 PM »
Hey there,

I'm not exactly sure what you're trying to do.  Can you explain a bit more in detail how your camera and character work/move about (Ex third person, over the top, click to move ect.)  The more info I got the better I can help with

If its a simple inverse though, just doing a check if the rotation is greater then 90 then using a multiply by -1 to inverse would work.

I feel like you may be making it a bit more complex then it needs to be but I need more info to help more.

Thanks

#### jeanfabre

• Hero Member
• Posts: 14938
• Official Playmaker Support
##### Re: Invert Horizontal Axis.
« Reply #2 on: April 02, 2019, 11:01:36 PM »
Hi,

you need to control your character "Relative" to itself, so where ever he's facing, press the "go right" key or control input has to be executed relative to itself, not relative to the world.

Bye,

Jean

#### bunnyrick

• Playmaker Newbie
• Posts: 12
##### Re: Invert Horizontal Axis.
« Reply #3 on: April 03, 2019, 06:04:40 AM »
Hey there,

I'm not exactly sure what you're trying to do.  Can you explain a bit more in detail how your camera and character work/move about (Ex third person, over the top, click to move ect.)  The more info I got the better I can help with

If its a simple inverse though, just doing a check if the rotation is greater then 90 then using a multiply by -1 to inverse would work.

I feel like you may be making it a bit more complex then it needs to be but I need more info to help more.

Thanks

It's for a top-down game. I'm moving the character using Get Axis, Get Axis Vector and Set Velocity. I also rotate the Camera with Get Key Down and Rotate in the Y Angle in world space and also rotating the player to the Mouse position.
So, when i rotate the camera left or right and point the character back (relative to the camera) with the mouse, its horizontal controls inverts, i don't know why.
« Last Edit: April 03, 2019, 06:12:11 AM by bunnyrick »

#### bunnyrick

• Playmaker Newbie
• Posts: 12
##### Re: Invert Horizontal Axis.
« Reply #4 on: April 03, 2019, 06:08:55 AM »
Hi,

you need to control your character "Relative" to itself, so where ever he's facing, press the "go right" key or control input has to be executed relative to itself, not relative to the world.

Bye,

Jean

Thanks for the reply. What actions should i use to do this? I'm using Get Axis and Set Velocity (rigidbody) to do the movement. I also rotate the player to the mouse position, wich also inverts the controls only when i point the character "back" relative to the camera.
« Last Edit: April 03, 2019, 06:16:24 AM by bunnyrick »

#### bunnyrick

• Playmaker Newbie
• Posts: 12
##### Re: Invert Horizontal Axis.
« Reply #5 on: April 03, 2019, 03:00:26 PM »
Does someone know how to fix the inverse movement issue when my character is rotated "backwards" relative to the camera?

#### jeanfabre

• Hero Member
• Posts: 14938
• Official Playmaker Support
##### Re: Invert Horizontal Axis.
« Reply #6 on: April 04, 2019, 12:21:23 AM »
Hi,

for this you need to compute the force to apply as a relative force, it's available in the addforce action, you choose "self" in the Space property.

Bye,

Jean

#### bunnyrick

• Playmaker Newbie
• Posts: 12
##### Re: Invert Horizontal Axis.
« Reply #7 on: April 04, 2019, 04:53:15 AM »
Hi,

for this you need to compute the force to apply as a relative force, it's available in the addforce action, you choose "self" in the Space property.

Bye,

Jean

Hi, thanks for the reply. I set the Set Velocity to World Space and it worked now.
I don't know why it wasn't working before...

#### bunnyrick

• Playmaker Newbie
• Posts: 12
##### Re: Invert Horizontal Axis.
« Reply #8 on: April 04, 2019, 07:13:35 AM »
Hi,

for this you need to compute the force to apply as a relative force, it's available in the addforce action, you choose "self" in the Space property.

Bye,

Jean

Hey @jeanfabre, when i rotate the camera using the Rotate action, all the controls inverses! Lets say if my character is facing down relative to the camera and if i want to walk Right, it goes in a completely different direction.

It only happens when i rotate the camera to a Y angle different than 0 while also rotates my character to the mouse.

I really need to know how to fix this.
« Last Edit: April 04, 2019, 07:34:25 AM by bunnyrick »

#### jeanfabre

• Hero Member
• Posts: 14938
• Official Playmaker Support
##### Re: Invert Horizontal Axis.
« Reply #9 on: April 04, 2019, 07:37:49 AM »
Hi,

Can you make a screencast or some screenshots showing when your player is moving properly and when he's not? Maybe I have i mind a different gameplay then you want to implement.

Bye,

Jean

#### bunnyrick

• Playmaker Newbie
• Posts: 12
##### Re: Invert Horizontal Axis.
« Reply #10 on: April 04, 2019, 11:46:35 AM »
Hi,

Can you make a screencast or some screenshots showing when your player is moving properly and when he's not? Maybe I have i mind a different gameplay then you want to implement.

Bye,

Jean

These movement mechanics i'm trying to make are:
-Move the character Horizontal/Vertical with WASD in 3D space.
-Have my character to be always facing the mouse position.
-Rotate the top-view camera (that is following the player) with Q and E in the Y Angle based on a Speed variable.

The Problem is:
Lets say if the camera and the player are rotated 90 degrees in the Y Angle and i press D to move right, the player will move Left or Down for example.
The controls inverts at every Y angle the camera is rotated to that is other than 0...

The images below shows my setup in Playmaker.

« Last Edit: April 04, 2019, 02:58:25 PM by bunnyrick »

#### bunnyrick

• Playmaker Newbie
• Posts: 12
##### Re: Invert Horizontal Axis.
« Reply #11 on: April 04, 2019, 01:11:32 PM »
@jeanfabre And in the image below is the camera rotated 45 degrees to the right, also inversing the horizontal/vertical movement.

#### jeanfabre

• Hero Member
• Posts: 14938
• Official Playmaker Support
##### Re: Invert Horizontal Axis.
« Reply #12 on: April 04, 2019, 11:21:38 PM »
Hi,

I see.

you need to use the camera object to find its own left and right side, and that's the direction vector you'll use to move your character.

use TransformDirection action on that camera with a given axis ( Vector(1,0,0) would be x axis) to get the world direction associated with the x axis of the camera.

Have a go at the above and let me know how it goes.

Bye,

Jean

#### bunnyrick

• Playmaker Newbie
• Posts: 12
##### Re: Invert Horizontal Axis.
« Reply #13 on: April 06, 2019, 12:12:29 PM »
Hi,

I see.

you need to use the camera object to find its own left and right side, and that's the direction vector you'll use to move your character.

use TransformDirection action on that camera with a given axis ( Vector(1,0,0) would be x axis) to get the world direction associated with the x axis of the camera.

Have a go at the above and let me know how it goes.

Bye,

Jean

Sorry for the late reply, but as i never used FSMs before, what goes where?
I would appreciate a screenshot or a step by step on how to do this.

#### bunnyrick

• Playmaker Newbie
• Posts: 12
##### Re: Invert Horizontal Axis.
« Reply #14 on: April 09, 2019, 05:24:51 AM »
I'm trying to use the Transform Direction action but need some help to setup it...