Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: Red on July 04, 2015, 09:07:03 PM

Title: The "Mouse Look" action (adjustment to add an inverted Y axis option.)
Post by: Red on July 04, 2015, 09:07:03 PM
So I needed to use this action but wanted to add in the option of inverting the Y axis...

Here's what I got... Note, I'm not sure if where I placed the changes would be the best or most appropriate... If you can think of a better way to do this that would be cleaner or more efficient, please let me know.

This is the only change to this action's code...

Variable/Field declaration
Code: [Select]
[Tooltip("Invert Y axis")]
public FsmBool invertY;

Added/changed code in the function.
Code: [Select]
float GetYRotation()
{

if (invertY.Value == true)
{
rotationY -= Input.GetAxis("Mouse Y") * sensitivityY.Value;
rotationY = ClampAngle(rotationY, minimumY, maximumY);
}
if (invertY.Value == false)
{
rotationY += Input.GetAxis("Mouse Y") * sensitivityY.Value;
rotationY = ClampAngle(rotationY, minimumY, maximumY);
}
return rotationY;
}

Other than that, the action is identical to the one that comes stock. (I'm unsure what the notes about rigidbodies are about... Maybe as I improve at coding in C# I'll understand it but I'm not 100% certain about it...)

(I tried initially to use a switch/case system but that didn't produce results... So I used the If statement. Not sure if that's the best or most ideal way of doing it... But it is what it is at this point for now.)
Title: Re: The "Mouse Look" action (adjustment to add an inverted Y axis option.)
Post by: 600 on July 04, 2015, 09:20:43 PM
Hi, vertical axis can be inverted with negative sensitivity value.