- Home /
How can I finish this script REALLY NEED HELP
Hi,I am an artiss, and i know nothing about Js script, I have spended four days to make my character move like this: In play mode, when I press and drag left mouse button, my character will rotate, and when I press and drag the right button, my character will move in XY plane, when I scroll wheel, it will zoom in and out. It pretty much like the navigation in Unity, just without the ALT button, I have search the whole internet to finish the script, but for now, I just make my character rotate and zoom, only one more thing left, I really do not know how to do it. Please help me! Here is the script so far. Thank u so much!!!
var target : Transform; var distance = 10.0;
var xSpeed = 250.0; var ySpeed = 120.0;
var yMinLimit = -20; var yMaxLimit = 80;
var distanceMin = 3; var distanceMax = 15;
private var x = 0.0; private var y = 0.0;
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 () { if (target && (Input.GetMouseButton(0) || Input.GetAxis("Mouse ScrollWheel")) ) { 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);
distance = Mathf.Clamp(distance - Input.GetAxis("Mouse ScrollWheel")*5, distanceMin, distanceMax);
var hit : RaycastHit;
if (Physics.Linecast (target.position, transform.position, hit)) {
distance -= hit.distance;
}
var position = rotation * Vector3(0.0, 0.0, -distance) + target.position;
transform.rotation = rotation;
transform.position = position;
}
}
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); }
An alternative would be to $$anonymous$$m up with a programmer. See the Collaboration section on forum.unity3d.com - an actual finished game has many thousands of lines of code written for it.
Your answer

Follow this Question
Related Questions
Different Camera changes work against each other? 1 Answer
Zoom and spanning not working together 0 Answers
allows users to view 360º content without a VR headset 0 Answers
Pick up, drop, rotate, and zoom a rigidbody gameObject 2 Answers
How do I rotate the camera upwards when zoom is close? 0 Answers