So i need some advice or ideeas:
i`ve wrote this camera control script and i want to know how to place the carachter an the side of the screen and to keep the rotation on orbit mode.
using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour
{
public LayerMask layer;
public Texture crosshair;
public Transform target;//camera orbit pivot(empty gameobject) child object of charachter
public Transform target1;//character
public float height;
public float distance;
public float rotationSpeed;
private float tempdistance;
public float yMin;
public float yMax;
public float l=50f;//GUI align
public float u=50f;//GUI align
private float x;
private float y;
private Quaternion rotation;
private Vector3 position;
private RaycastHit hit;
void Update()
{
}
void LateUpdate ()
{
x+=10*Input.GetAxis("Mouse X");
y+=10*Input.GetAxis("Mouse Y");
if(y>yMax)
y=yMax;
else if(y0.1)
target1.rotation=Quaternion.Slerp(target1.rotation,Quaternion.Euler(0,x,0),rotationSpeed*Time.deltaTime);
//smooth rotation towards the camera rotation when walking
}
void OnGUI()
{
GUI.Label(new Rect((Screen.width/4)*3-l,(Screen.height/4)-u,crosshair.width,crosshair.height),crosshair);
}
}
![alt text][1]
[1]: /storage/temp/15205-untitled.jpg
↧