Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Satrio on September 22, 2011, 10:57:46 AM

Title: mouse move doesnt clamp x [solved]
Post by: Satrio 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
Title: Re: mouse move doesnt clamp x
Post by: Satrio on September 22, 2011, 11:29:56 AM
The scene I am working on:
http://www.successfulhero.com/goblin/WebPlayer/WebPlayer.html (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?
 
Title: Re: mouse move doesnt clamp x
Post by: qholmes 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
Title: Re: mouse move doesnt clamp x
Post by: qholmes 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
Title: Re: mouse move doesnt clamp x
Post by: Alex Chouls 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...
Title: Re: mouse move doesnt clamp x
Post by: Satrio on September 22, 2011, 02:29:38 PM
goody goody!!
Title: Re: mouse move doesnt clamp x
Post by: Alex Chouls 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...