Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Temas - Sebas92

#1
General (Antiguo) / Ayuda con error script
Julio 21, 2015, 04:33:07 PM
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);
}
}
 
#2
Hola, hice un ascensor y un script para que cuando el personaje lo toque este se vuelva padre del personaje y asi moverlo junto con el ascensor pero me salta un error en el script:   Assets/PadrePlatform.cs(7,51): error CS0120: An object reference is required to access non-static member `UnityEngine.GameObject.transform'   necesito ayuda.
 
script:
 

using UnityEngine;
using System.Collections;
public class PadrePlatform : MonoBehaviour {
void OnTriggerEnter(Collider col){
  col.transform.parent = GameObject.transform;
}
void OnTriggerExit(Collider col) {
  col.transform.parent = null;
}
}

 
 
#3
Hola, quisiera saber que tipo de script necesito para activar una animación mecanim con el movimiento del mouse.
#4
General (Antiguo) / Dudas sobre mecanim
Junio 06, 2015, 04:08:03 PM
Hola tengo 2 preguntas:
1) Tengo 2 animaciones para mecanim de apuntar un arma en tercera persona, una que mira hacia arriba y otra hacia abajo y no tengo ni idea de como activarlas para que cuando mueva el mouse apunte el arma hacia arriba y abajo.
 
2) Que clase de script necesito para activar las animaciones de una new layer de mecanim con un avatar mask.
#5
Hola, hice un script para activar la animación de apuntar en mi personaje, pero la verdad no se mucho de scripts ni de mecanim, la animación se activa pero quiero que se siga reproduciendo siempre y cuando mantenga presionado el click derecho y se desactive cuando lo suelte, y otra cosa en el mecanim que clase de parametro tengo que ponerle? le puse un trigger y lo llame apunta, con esto logre que se active la animación pero para desactivarla tengo que apretar click derecho otra vez
 
using UnityEngine;
using System.Collections;
public class animacionapuntar : MonoBehaviour {
Animator ani;
void  Start (){
 
  ani = GetComponent<Animator> ();
}
 
void  Update (){
 
  if (Input.GetButtonDown ("Fire2")) {
   ani.SetBool ("apunta", true);
  }
 
  else
 
  {
   ani.SetBool ("apunta", false);
  }
 
 
}
}
#6
General (Antiguo) / Ayuda con un script
Mayo 31, 2015, 05:17:06 AM
Hola, tengo un script cuya función es girar alrededor del personaje controlado por el mouse igual que el MouseOrbitScript pero este es mas complejo, el problema viene cuando el personaje tendria que rotar hacia donde ve la camara pero no lo hace, no se que le falta aqui dejo el script:

using UnityEngine;
using System.Collections;
using Globals;
public class PlayerCamera : MonoBehaviour
{
    #region Public Fields & Properties
public float yMinLimit = -85f;
public float yMaxLimit = 85f;
public float normalFov = 60f;
public float zoomFov = 30f;
public float lerpSpeed = 8.0f;
public float positionLerp = 6f;
public float normalHeight = 1.5F;
public float normalAimHeight = 1.8f;
public float minHeight = 0.5f;
public float maxHeight = 2f;
public float normalDistance = 2.5f;
public float normalAimDistance = 1f;
public float minDistance = 0.2f;
public float maxDistance = 2.5f;
public bool orbit;
public Transform target;
public Transform player;
public Vector2 speed = new Vector2 (135f, 135f);
public Vector2 aimSpeed = new Vector2 (100f, 100f);
public Vector2 maxSpeed = new Vector2 (100f, 100f);
public LayerMask hitLayer;
public Vector3 normalDirection = new Vector3 (-1f, 0f, 0.3f);
public Vector3 aimDirection = new Vector3 (-1f, 0f, 0.7f);
#endregion
    #region Private Fields & Properties
private float _x = 0.0f;
private float _y = 0.0f;
private float _deltaTime;
private float _targetDistance;
private float _targetHeight;
private Transform _camTransform;
private Vector3 _position;
private Vector3 _camDir;
private Vector3 _camPos;
private Quaternion rotation;
private PlayerController playerController;
    #endregion
    #region Getters & Setters
public float Y { get { return _y; } }
public float x { get { return _x; } }
    #endregion
    #region System Methods
    private void Start()
    {
  Screen.showCursor = false;
  Screen.lockCursor = true;
  if (target == null || player == null)
  {
   Destroy (this);
   return;
  }
  target.parent = null;
  _camTransform = transform;
  Vector3 angles = _camTransform.eulerAngles;
  _x = angles.y;
  _y = angles.x;
  playerController = player.GetComponent<PlayerController> ();
  _targetDistance = normalDistance;
  _camPos = player.position + new Vector3 (0, normalHeight, 0);
    }
    // Update is called once per frame
    private void Update()
    {
        if (Input.GetButtonDown(PlayerInput.Cancel))
  {
   Screen.showCursor = !Screen.showCursor;
   Screen.lockCursor = !Screen.lockCursor;
  }
  if (Input.GetAxis (PlayerInput.Horizontal) != 0.0 || Input.GetAxis (PlayerInput.Vertical) != 0.0 || playerController.aim)
  {
   GoToOrbitMode (false);
  }
  if (!orbit && playerController.idletimer > 0.1)
  {
   GoToOrbitMode (true);
  }
    }
    public void LateUpdate()
    {
  _deltaTime = Time.deltaTime;
  GetInput ();
  RotatePlayer ();
  CameraMovement ();
    }
    #endregion
    #region Custom Methods
    private void GoToOrbitMode(bool state)
{
  orbit = state;
  playerController.idletimer = 0.0f;
}
private void GetInput()
{
  Vector2 a = playerController.aim ? aimSpeed : speed;
  _x += Mathf.Clamp (Input.GetAxis (PlayerInput.MouseX) * a.x, -maxSpeed.x, maxSpeed.x) * _deltaTime;
  _y -= Mathf.Clamp (Input.GetAxis (PlayerInput.MouseY) * a.y, -maxSpeed.y, maxSpeed.y) * _deltaTime;
  _y = ClampAngle(_y, yMinLimit, yMaxLimit);
}
public static float ClampAngle(float angle, float min, float max)
{
  if (angle < -360) angle += 360;
  if (angle > 360) angle -= 360;
  return Mathf.Clamp(angle, min, max);
}
private void RotatePlayer()
{
  if (!orbit)playerController.targetYRotation = _x;
}
public void CameraMovement()
{
  if (playerController.aim)
  {
   camera.fieldOfView = Mathf.Lerp(camera.fieldOfView, zoomFov, _deltaTime * lerpSpeed);
   _camDir = (aimDirection.x * target.forward) + (aimDirection.z * target.right);
   _targetHeight = normalAimHeight;
   _targetDistance = normalAimDistance;
  }
  else
  {
   camera.fieldOfView = Mathf.Lerp(camera.fieldOfView, normalFov, _deltaTime * lerpSpeed);
   _camDir = (normalDirection.x * target.forward) + (normalDirection.z * target.right);
   _targetHeight = normalHeight;
   _targetDistance = normalDistance;
  }
  _camDir = _camDir.normalized;
  _camPos = player.position + new Vector3 (0, _targetHeight, 0);
  RaycastHit hit;
  if (Physics.Raycast (_camPos, _camDir, out hit, _targetDistance + 0.2f, hitLayer))
  {
   float t = hit.distance - 0.1f;
   t -= minDistance;
   t /= (_targetDistance - minDistance);
   _targetHeight = Mathf.Lerp(maxHeight, _targetHeight, Mathf.Clamp(t, 0.0f, 1.0f));
   _camPos = player.position + new Vector3(0, _targetHeight, 0);
   _targetDistance = hit.distance - 0.1f;
  }
  Vector3 lookPoint = _camPos;
  lookPoint += (target.right * Vector3.Dot ((_camDir * _targetDistance), target.right));
  _camTransform.position = _camPos + (_camDir * _targetDistance);
  _camTransform.LookAt(lookPoint);
  target.position = _camPos;
  target.rotation = Quaternion.Euler(_y, _x, 0);
}
    #endregion
}
#7
Hola, me he descargado este personaje http://tf3dm.com/3d-model/army-pilot-fully-rigged-animated-20-animations-57044.html" rel="external nofollow">http://tf3dm.com/3d-model/army-pilot-fully-rigged-animated-20-animations-57044.html dicho personaje viene con animaciones, he tratado de hacer la animación de caminar con mecanim pero cuando le doy play reproduce la animación pero no se mueve queda estatico en el lugar, un poco de ayuda
#8
Hola, estoy haciendo un juego shooter en tercera persona y quiero saber como crear animaciones para que estas las puedas utilizar en el mecanim, he visto tutoriales que usan el Raw Mocap Data para explicar como animar a tu personaje pero no explican como crear la animación, si alguien sabe de algun tutorial o si podrian explicar esto ayudaria mucho.