- Home /
 
Too subjective and argumentative
Error with gun aim to the mouse
Okey , my problem is when i'm aiming to the cursor , in 2d mode , the gun move in all axes.
Wanted movement

Only in the 2d dimension ..
PD1: I was searching a lot of things and nothing can help me.
PD2: This movement is like the game Rochard , but only with a 3d model , only rotation no hips , etc...
Answer by programmrzinc · Oct 05, 2012 at 05:43 PM
This might help. I dont know what axis angle you are trying to clamp... :(
 function Update() {
 
 var input = Input.GetAxis("Mouse Y");
    
 
 if(input != 0) {
     //We really only need to do the rest if we actually moved some.
     angles.x += rotationVelocity * Time.deltaTime * input;
 
     angles.x = Mathf.Clamp(angles.x, 0, 0);
 
     transform.eulerAngles.x = angles.x;
 
 }
 }
 
              var rotationVelocity=20;
if(input!=0) {
 var angles.x += rotationVelocity * Time.deltaTime * input;
 angles.x = $$anonymous$$athf.Clamp(angles.x, 0, 0);
 transform.eulerAngles.x = angles.x;
   
 
                  } */ Thanks for your time to answer this question . I try to put it in the code , but it give me errors , i put rotationVelocity as a variable , but it give me error with angles code(I think it haven't variable) Cheers
I'm trying to clamp the x axis , i want only 2d movement Thanks in advance