Código: Selecionar todos
using UnityEngine;
using System.Collections;
public class
câmerarotation :MonoBehaviour
{
public float moveSpeed = 5.0f;
public float drag = 0.5f;
public float terminalRotationSpeed = 25.0f;
public Vector3 MoveVector { set; get; }
public virtualJoystick joyStick { set; get; }
private Rigidbody thisRigidbody;
private Transform camTransform;
void Start()
{
thisRigidbody = gameObject.AddComponent();
thisRigidbody.maxAngularVelocity = terminalRotationSpeed;
thisRigidbody.drag = drag;
}
void Update()
{
MoveVector = PoolInput();
Move();
}
private void Move()
{
thisRigidbody.AddForce((MoveVector * moveSpeed));
}
private Vector3 PoolInput()
{
Vector3 dir = Vector3.zero;
dir.x = joyStick.Horizontal(); // dir.x = Input.GetAxis("horizontal");
dir.z = joyStick.Vertical // dir.z = Input.GetAxis("Vertical");
if (dir.magnitude > 1)
dir.Normalize();
return dir;
}
private Vector3 RotateWithView()
{
if (camTransform != null)
{
Vector3 dir = camTransform.TransformDirection(MoveVectorVector);
dir.Set(dir.x, 0, dir.z);
return dir.normalized * MoveVector.magnitude;
}
else
{
//camTransfor = Camera.main.transform;
camTransform = GetComponent().CamTransform;
return MoveVector;
}
}
estou com problemas com esse script ele e aquela câmera with quando eu arrasto ele esta dando erro se alguém poder me ajudar desde já obrigado!!