Noticias

¡RECUERDA QUE SI ERES UN NUEVO USUARIO, DEBES PRESENTARTE PARA PODER PUBLICAR MENSAJES! | TENEMOS CANAL OFICIAL DE TELEGRAM: t.me/unity3dspain

Ayuda con error script

Iniciado por Sebas92, Julio 21, 2015, 04:33:07 PM

Tema anterior - Siguiente tema
Julio 21, 2015, 04:33:07 PM Ultima modificación: Julio 21, 2015, 04:48:00 PM por Sebas92
Hola necesito ayuda con este script sigo teniendo el mismo error y nose como solucionarlo: FreeCameraLook.cs(31,57): error CS1061: Type `UnityEngine.Camera[]' does not contain a definition for `transform' and no extension method `transform' of type `UnityEngine.Camera[]' could be found (are you missing a using directive or an assembly reference?) 
using Unit***itor;

public class FreeCameraLook : Pivot {

[SerializeField] private float moveSpeed = 5f;
[SerializeField] private float turnSpeed = 1.5f;
[SerializeField] private float turnsmoothing = .1f;
[SerializeField] private float tiltMax = 75f;
[SerializeField] private float tiltMin = 45f;
[SerializeField] private bool lockCursor = false;


private float lookAngle;
private float tiltAngle;

private const float LookDistance = 100f;

private float smoothX = 0;
private float smoothY = 0;
private float smoothXvelocity = 0;
private float smoothYvelocity = 0;


protected override void Awake()
{
   base.Awake ();

   Screen.lockCursor = lockCursor;

   cam = GetComponentsInChildren<Camera>().transform;

   pivot = cam.parent;
}


protected override void Update ()
{
   base.Update ();

   HandleRotationMovement ();

   if (lockCursor && Input.GetMouseButtonUp (0))
   {
      Screen.lockCursor = lockCursor;
   }
}

void OnDisable()
{
   Screen.lockCursor = false;
}

protected override void Follow (float deltaTime)
{
   transform.position = Vector3.Lerp(transform.position, target.position, deltaTime * moveSpeed);
}

void HandleRotationMovement()
{
   float x = Input.GetAxis ("Mouse X");
   float y = Input.GetAxis ("Mouse Y");

   if(turnsmoothing > 0)
   {
      smoothX = Mathf.SmoothDamp(smoothX,x,ref smoothXvelocity, turnsmoothing);
      smoothY = Mathf.SmoothDamp(smoothY,y,ref smoothYvelocity, turnsmoothing);
   }
   else
   {
      smoothX = x;
      smoothY = y;
   }

   lookAngle += smoothX * turnSpeed;

   transform.rotation = Quaternion.Euler (0f, lookAngle, 0);

   tiltAngle -= smoothY * turnSpeed;
   tiltAngle = Mathf.Clamp(tiltAngle, - tiltMin, tiltMax);

   pivot.localRotation = Quaternion.Euler (tiltAngle, 0, 0);
}
}
 

Julio 21, 2015, 06:37:27 PM #1 Ultima modificación: Enero 01, 1970, 01:00:00 AM por Antonio
El objeto de la cámara tiene algún hijo con su transform para poder cogerlo en esta línea?
 
cam = GetComponentsInChildren<Camera>().transform;
Si no lo tiene, puede ser la causa del problema. Que se quede sin saber que hacer. O.ò

Etiquetas: