- Home /
Question by
Seve2 · Jul 26, 2020 at 06:39 AM ·
gameobjecttouch controlsclamped rotation
how to clamp the rotational values of a gameobject? I am using a touch drag input to control the values of the gameobject which is not in a fixed position in 3d space
I am using a touch drag input to control the rotation of the object. How can I clamp the rotation of the z value in the script? The game object I am using touch input to control is not in a fixed position in 3d space. This makes it difficult for me to clamp. I need to clamp it from the RotateSelected script.
public void RotateSelected(float rate)
{
lamp2Rotate.transform.eulerAngles += Vector3.forward * rate;
}
I call the below code in update
if (_isRotating)
{
// offset
_mouseOffset = (Input.mousePosition - _mouseReference);
// apply rotation
_rotation.y = -(_mouseOffset.x + _mouseOffset.y) * _sensitivity;
// rotate
//stand.transform.Rotate(_rotation);
// store new mouse position
_mouseReference = Input.mousePosition;
}
RotateSelected(_rotation.y);
Blockquote
Comment
Your answer
Follow this Question
Related Questions
Change the rotation of Z through swipe 0 Answers
Rhythm Game - When I touch an object with mobile in only activates 80% of the time... 1 Answer
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers
GetComponent of ALL clones? 2 Answers
Projectile not 'projecting' because i have to use "var xxx : GameObject = Instantiate" 2 Answers