I was looking in help file and I found only EventType.ScrollWheel and I don’t know how to use that and it’s not explained in help file, and I think it can’t help me because it doesn’t indicates WHEN I scroll mouse wheel
I was trying to find anything related with mouse wheel scrolling in Event. (because it is similar to pressing button) but didn’t find anything, plz help.
This is a modification on the original MouseOrbit to include a non target and wheel mouse. Its probably not exactly what you want, but it has the parts for the wheel mouse in it.
var targetObj : Transform;
var wheelSpeed=2.0;
var minDistance = 20.0;
var maxDistance=50.0;
private var distance = minDistance;
private var currentDistance = maxDistance;
var xSpeed = 250.0;
var ySpeed = 120.0;
var yMinLimit = -20;
var yMaxLimit = 80;
private var x = 0.0;
private var y = 0.0;
@script AddComponentMenu("Camera-Control/Mouse Orbit")
function Start () {
var angles = transform.eulerAngles;
x = angles.y;
y = angles.x;
// Make the rigid body not change rotation
if (rigidbody)
rigidbody.freezeRotation = true;
}
function LateUpdate () {
var targetPos=Vector3.zero;
if(targetObj)targetPos=targetObj.position;
x += Input.GetAxis("Mouse X") * xSpeed * 0.02;
y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02;
y = ClampAngle(y, yMinLimit, yMaxLimit);
var rotation = Quaternion.Euler(y, x, 0);
var position = rotation * Vector3(0.0, 0.0, -distance) + targetPos;
transform.rotation = rotation;
transform.position = position;
currentDistance -= Input.GetAxis("Mouse ScrollWheel") * wheelSpeed;
currentDistance=Mathf.Clamp(currentDistance,minDistance, maxDistance);
distance=Mathf.Lerp(distance, currentDistance, 2.0 * Time.deltaTime);
transform.position=targetPos;
transform.Translate(-Vector3.forward * distance);
}
static function ClampAngle (angle : float, min : float, max : float) {
if (angle < -360)
angle += 360;
if (angle > 360)
angle -= 360;
return Mathf.Clamp (angle, min, max);
}
nice I like that but that is not what I wanted, maybe I’ll need it later, cool thing, maybe I’ll need it later, it would be cool to spin around ONLY when I press shift button or something like that,
and I think it is easier to make it with function Transform.RotateAround
what I need is WHEN I rotate Mouse wheel to zoom in or zoom out
probably I’ll have to make any kind of code for starting, because people probably think that I haven’t tried to do anything, but problem is where to start, where too look in the help for functions which are controlled by mouse wheel
like when I have
if (Input.GetKey (KeyCode.W))
{
[COLOR="green"]DO SOMETHING TRIGGERED WITH "W" KEY[/COLOR]
}
now I need something like
if (Input.GetKey (KeyCode.[COLOR="red"]MouseWheelspin[/COLOR]))
{
[COLOR="green"]DO SOMETHING TRIGGERED WITH Mouse Wheel spin[/COLOR]
}