i need help, can someone make this for me? convert this script to c# please…
//LookAt
var damping = 6.0;
var smooth = true;
// The target we are following
var target : Transform;
var CamTarget : Transform;
var counter = 0;
// The distance in the x-z plane to the target
var distance = 10.0;
// the height we want the camera to be above the target
var height = 5.0;
// How much we
var heightDamping = 2.0;
var rotationDamping = 3.0;
var xSpeed = 250.0;
var ySpeed = 120.0;
var yMinLimit = -20;
var yMaxLimit = 80;
private var x = 0.0;
private var y = 0.0;
// Place the script in the Camera-Control group in the component menu
@script AddComponentMenu("Camera-Control/Mouse Orbit RPG")
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 () {
Counter();
// Early out if we don't have a target
if (!target)
return;
//Ativa orbital botão direito do mouse
if(Input.GetMouseButton(1)){
counter = 0;
if (target) {
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) + target.position;
transform.rotation = rotation;
transform.position = position;
}
}else{
// CamTarget.position = Vector3(target.transform.position.x, target.transform.position.y + height, target.transform.position.z - 10);
//lookAt
if (target) {
if (smooth)
{
// Look at and dampen the rotation
var Lrotation = Quaternion.LookRotation(target.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, Lrotation, Time.deltaTime * damping);
}
else
{
// Just lookat
transform.LookAt(target);
}
}
if(counter == 4){
// Calculate the current rotation angles
var wantedRotationAngle = target.eulerAngles.y;
var wantedHeight = target.position.y + height;
var currentRotationAngle = transform.eulerAngles.y;
var currentHeight = transform.position.y;
// Damp the rotation around the y-axis
currentRotationAngle = Mathf.LerpAngle (currentRotationAngle, wantedRotationAngle, rotationDamping * Time.deltaTime);
// Damp the height
currentHeight = Mathf.Lerp (currentHeight, wantedHeight, heightDamping * Time.deltaTime);
// Convert the angle into a rotation
var currentRotation = Quaternion.Euler (0, currentRotationAngle, 0);
// Set the position of the camera on the x-z plane to:
// distance meters behind the target
transform.position = target.position;
transform.position -= currentRotation * Vector3.forward * distance;
// Set the height of the camera
transform.position.y = currentHeight;
// Always look at the target
transform.LookAt (target);
}
}
}
function Counter(){
if(counter == 0){
yield WaitForSeconds(1);
counter = 1;
}
if(counter == 1){
yield WaitForSeconds(1);
counter = 2;
}
if(counter == 2){
yield WaitForSeconds(1);
counter = 3;
}
if(counter == 3){
yield WaitForSeconds(1);
counter = 4;
}
}
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);
}
thanks!