Unity Spain

Post Antiguos => General (Antiguo) => Mensaje iniciado por: Gastonspas en Enero 06, 2018, 10:25:34 PM

Título: Problema con ruedas
Publicado por: Gastonspas en Enero 06, 2018, 10:25:34 PM
Hola muy buenas a todos tengo un problema con las ruedas no se por que hacen eso (imagen abajo)
 
 
 

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[System.Serializable]
public class AxleInfo {
public WheelCollider leftWheel;
public WheelCollider rightWheel;
public bool motor;
public bool steering;
}
public class SimpleCarControler : MonoBehaviour {
public List<AxleInfo> axleInfos;
public float maxMotorTorque;
public float maxSteeringAngle;
// finds the corresponding visual wheel
// correctly applies the transform
public void ApplyLocalPositionToVisuals(WheelCollider collider)
{
   if (collider.transform.childCount == 0) {
      return;
   }
   Transform visualWheel = collider.transform.GetChild(0);
   Vector3 position;
   Quaternion rotation;
   collider.GetWorldPose(out position, out rotation);
   visualWheel.transform.position = position;
   visualWheel.transform.rotation = rotation;
}
public void FixedUpdate()
{
   float motor = maxMotorTorque * Input.GetAxis("Vertical");
   float steering = maxSteeringAngle * Input.GetAxis("Horizontal");
   foreach (AxleInfo axleInfo in axleInfos) {
      if (axleInfo.steering) {
         axleInfo.leftWheel.steerAngle = steering;
         axleInfo.rightWheel.steerAngle = steering;
      }
      if (axleInfo.motor) {
         axleInfo.leftWheel.motorTorque = motor;
         axleInfo.rightWheel.motorTorque = motor;
      }
      ApplyLocalPositionToVisuals(axleInfo.leftWheel);
      ApplyLocalPositionToVisuals(axleInfo.rightWheel);
   }
}
}

 
 
 
 (//<fileStore.core_Attachment>/monthly_2018_01/5a513ec089c68_Sinttulo2.png.8f6020ddc0a6f576a870c0f1ac784b98.png)
 (//<fileStore.core_Attachment>/monthly_2018_01/5a513eba3e607_Sinttulo.png.670e0db0979c819e4c7a682b35d63514.png)
Título: Problema con ruedas
Publicado por: leocub58 en Enero 07, 2018, 12:17:57 AM
Es por el objeto padre, mete las ruedas en un GameObject vacío
Título: Problema con ruedas
Publicado por: Gastonspas en Enero 07, 2018, 03:13:52 AM
Cita de: leocub58 date=1515280677Es por el objeto padre, mete las ruedas en un GameObject vacío
   


Como vendría ah ser