playMaker

Author Topic: mouse move doesnt clamp x [solved]  (Read 3897 times)

Satrio

  • Junior Playmaker
  • **
  • Posts: 67
mouse move doesnt clamp x [solved]
« on: September 22, 2011, 10:57:46 AM »
If I put in limits on "Mouse Move" for x, it doesnt take these into consideration.

If I check the script for "Mouse move" I only see a "clamp" expression on the Y axis.

Howcome? X is not possible or forgotten?

Need to clamp the X...please!

/s
« Last Edit: October 05, 2011, 01:53:22 PM by alexchouls »

Satrio

  • Junior Playmaker
  • **
  • Posts: 67
Re: mouse move doesnt clamp x
« Reply #1 on: September 22, 2011, 11:29:56 AM »
The scene I am working on:
http://www.successfulhero.com/goblin/WebPlayer/WebPlayer.html

I have parented the camera to an empty gameobject and clamped its "MouseLook" values
You can see that it clamps up down, but not sideways.

Feature request:

A way to remap the values? Map mouse X to object axis Y, etc..
Also to see if the coordinates are local or Global(World)?

Also to include "Z"?

I tried changing the "MouseLook" script by copying the RotationY clamp code and replacing Y with X.
It almost worked although not for negative x values. Please help?
 

qholmes

  • 1.2 Beta
  • Hero Member
  • *
  • Posts: 509
Re: mouse move doesnt clamp x
« Reply #2 on: September 22, 2011, 12:02:21 PM »
Hmm that script is very strange... kind of disjointed in how it is written.. I dont quite get what is going on at first glance but you are correct something is messed up.

I will mess with it a bit and see if i can get something working...

Unless someone else has a quick fix.

Q

qholmes

  • 1.2 Beta
  • Hero Member
  • *
  • Posts: 509
Re: mouse move doesnt clamp x
« Reply #3 on: September 22, 2011, 12:25:34 PM »
So if you change the X and Y case to this:
Code: [Select]
case RotationAxes.MouseXAndY:

{

//var rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX.Value;

rotationX += Input.GetAxis("Mouse X") * sensitivityX.Value;

rotationX = Mathf.Clamp(rotationX, minimumX.Value, maximumX.Value);



rotationY += Input.GetAxis("Mouse Y") * sensitivityY.Value;

rotationY = Mathf.Clamp(rotationY, minimumY.Value, maximumY.Value);



transform.localEulerAngles = new Vector3(-rotationY, -rotationX, 0);

}

break;

And you also add the following declaration for the rotationX variable..

Code: [Select]
float rotationY;

float rotationX;

Then i think you get something that is closer to what you are looking for. I am not sure exactly how this Action is supposed to work. The other X case i did not change.. Is this closer to what you wanted? If so i could send a whole new Action..

Q

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: mouse move doesnt clamp x
« Reply #4 on: September 22, 2011, 12:53:04 PM »
This action was a quick conversion of the MouseLook monobehaviour that ships with Unity. However it looks like the original script didn't really enforce the limits properly, so the action has inherited some bugs... I'll take a look at improving this action...

Satrio

  • Junior Playmaker
  • **
  • Posts: 67
Re: mouse move doesnt clamp x
« Reply #5 on: September 22, 2011, 02:29:38 PM »
goody goody!!

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: mouse move doesnt clamp x
« Reply #6 on: September 22, 2011, 02:58:59 PM »
Please try the attached MouseLook action.

This should clamp X properly.

It doesn't have the option to swap X and Y, but it should be easier to see how to do that with this script.

Let me know if you run across bugs...