playMaker

Author Topic: Rotate joint within a define range [SOLVED]  (Read 8918 times)

sopothetocho

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Rotate joint within a define range
« Reply #15 on: January 10, 2013, 02:24:08 PM »
Here its a picture of the state. The jigglering happens even when there no animation played by the character.EDIT: actually I think the rotation its getting overriding by the animations
« Last Edit: January 10, 2013, 02:42:27 PM by sopothetocho »

sopothetocho

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Rotate joint within a define range
« Reply #16 on: January 10, 2013, 08:54:46 PM »
I solved this by creating an script from the Mouselook script. Im gonna post the code here for anyone who may be looking for something similar

Code: [Select]
using UnityEngine;
using System.Collections;







[AddComponentMenu("Camera-Control/third-person-camera")]
public class MouseLook2 : MonoBehaviour {

public enum RotationAxes { MouseXAndY = 0 }
public RotationAxes axes = RotationAxes.MouseXAndY;
public float sensitivityX = 15F;
public float sensitivityY = 15F;

public float minimumX = -360F;
public float maximumX = 360F;

public float minimumY = -60F;
public float maximumY = 60F;

float rotationY = 0F;
float rotationX = 0F;
// LateUpdate overrides character animation
void LateUpdate ()
{
if (axes == RotationAxes.MouseXAndY)
{
rotationX += Input.GetAxis ("Mouse X") * sensitivityX;
rotationX = Mathf.Clamp (rotationX, minimumX, maximumX);

rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);

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

void Start ()
{
// Make the rigid body not change rotation
if (rigidbody)
rigidbody.freezeRotation = true;
}
}



jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Rotate joint within a define range [SOLVED]
« Reply #17 on: January 11, 2013, 02:05:55 AM »
Hi,

 Excellent. And you'll note that indeed you can use negative angles ( "transform.localEulerAngles = new Vector3(0, rotationX, -rotationY);" -rotationY is negative, just so you know you can tell a transform to rotate -30 or something.

 Bye,

 Jean