Buenas a todos, tengo un problema con este script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerCamera : MonoBehaviour {
// Script hecho por mi (Stunx)
// Nombre: PlayerCamera | Version: 1.0 | Descripcion: Un controlador para camara incluido con colision.
public Transform target;
public float distance = 3.0f;
public float maxDistance = 4.0f;
public float xSpeed = 250.0f;
private float x = 0.0f;
private float y = 0.0f;
void Start()
{
var angles = transform.eulerAngles;
x = angles.y;
y = angles.x;
if (GetComponent<Rigidbody>())
{
GetComponent<Rigidbody>().freezeRotation = true;
}
}
void FixedUpdate()
{
RaycastHit hit = new RaycastHit(); Ray ray = new Ray(transform.position, target.position);
Debug.DrawLine(transform.position, target.position, Color.red);
if (Physics.Raycast(ray, out hit, maxDistance))
{
distance = hit.distance + 1f;
print("Tocaste la pared!");
}
else print("Dejaste la pared :(");
}
void Update()
{
if (target)
{
x += Input.GetAxis("Mouse X") *