playMaker

Author Topic: The "Mouse Look" action (adjustment to add an inverted Y axis option.)  (Read 2620 times)

Red

  • Hero Member
  • *****
  • Posts: 563
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.)
« Last Edit: July 05, 2015, 10:19:36 AM by Red »

600

  • Beta Group
  • Hero Member
  • *
  • Posts: 713
    • Flashing Lights
Hi, vertical axis can be inverted with negative sensitivity value.