Unity3D Movimiento de Ruedas wheel Move

Vamos a realizar un juego para android para despues colgarlo a Play Store, bien vamos a crear un coche en Blender para despues importarlo a Unity3D


Aquí ya tenemos nuestra Camioneta ahora lo que vamos hacer es importarlo a nuestro Unity en FBX.


Una vez Exportado el Formato FBX abrimos nuestro Unity, y importamos nuestra Camioneta

Aquí tenemos nuestra camioneta y sus cuatro Ruedas que Son Cylinder,Cylinder_001,Cylinder_002,Cylinder_003, esas serian nuestras cuatro ruedas a las que vamos a cambiar de nombre

Aquí tenemos nuestras 4 ruedas, ahora vamos a crear un objeto Vació al que vamos a poner Wheel Collider,

a la rueda la incorporamos en el objeto vació le creamos otro objeto vació al que llamaremos FL y le incorporamos el Wheel Collider y deberia quedar tal cual esta en la imagen, y hacemos lo mismo las las 3 ruedas restantes


Aquí tenemos las 4 ruedas WheelCollider se las asignamos a nuestro  coche, ahora vamos a nuestro Camión y le asignamos el siguiente Script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class pt : MonoBehaviour
    public WheelCollider wheelFL;
    public WheelCollider wheelFR;
    public WheelCollider wheelRL;
    public WheelCollider wheelRR;

    public Transform wheelFL_Trans;
    public Transform wheelFR_Trans;
    public Transform wheelRL_Trans;
    public Transform wheelRR_Trans;

    public float fuerza;     

    public float velocidad; 

    public float velocidadactual;

    public float angulodireccion;
    public float giro;    
    private Rigidbody rigidBody;

    void Start()
        rigidBody = GetComponent<Rigidbody>();

    void FixedUpdate()
        velocidadactual = 2 * Mathf.PI * wheelFL.radius * wheelFL.rpm * 60 / 1000;
            wheelFL.motorTorque = fuerza * Input.GetAxis("Vertical");
            wheelFR.motorTorque = fuerza * Input.GetAxis("Vertical");
            wheelRL.motorTorque = fuerza * Input.GetAxis("Vertical");
            wheelRR.motorTorque = fuerza * Input.GetAxis("Vertical");

        velocidad = GetComponent<Rigidbody>().velocity.magnitude * 15;

        giro = angulodireccion * Input.GetAxis("Horizontal");
        wheelFL.steerAngle = giro;
        wheelFR.steerAngle = giro;


    void Update()
        wheelFL_Trans.Rotate(0, 0, wheelFL.rpm / 60 * 360 * Time.deltaTime);
        wheelFR_Trans.Rotate(0, 0, wheelFR.rpm / 60 * 360 * Time.deltaTime);
        wheelRL_Trans.Rotate(0, 0, wheelRL.rpm / 60 * 360 * Time.deltaTime);
        wheelRR_Trans.Rotate(0, 0, wheelRR.rpm / 60 * 360 * Time.deltaTime);

        Vector3 RuedaDireccion = wheelFL_Trans.localEulerAngles;
        RuedaDireccion.y = giro + 90;
        wheelFL_Trans.localEulerAngles = RuedaDireccion;
        wheelFR_Trans.localEulerAngles = RuedaDireccion;




una vez que tengamos  hecho le asignamos las ruedas y los WheeCollider que hemos creado

Y ya lo tendríamos.

10 comentarios

  1. yeah. that’s whate y was exploring for. thanks. Luciene Ives Gavrila

  2. pode-se aprender algo novo aqui todos os dias. Eu sou um regular para a maioria deses blogs, mas ainda enão sabia sobre um par deles. Amamaria Law Phiona

  3. Its such as you read my thoughts! You apear to know so much aproximately this, such as you wrote the e book in ite or something. y fel that you juste could do with a few percente to power the message home a litle bit, bute other than that, that is wonderful blog. a fantastic read. Il certainly be back. Damita erberte Bowles

  4. y loved as much as you wil receive performed proper ere. The caricature is tasteful, your authored material estylish. nonetheles, you comand get boughte an nervousnes over that you would lique be turning in the following. il definitely come further previously again since precisely the similar juste aboute a lote incesantly inside of case you protecte this increase. Leland Packston Veronike

  5. Some genuinely prize contente on this web site , saved to fav. Roda gerhardte Sholom

  6. It is truly a great and helpful piece of information.
    I am happy that you shared this useful info with us.

    Please keep us informed like this. Thank you for sharing.

  7. We are a bunch of volunteers and opening a new scheme in our community.
    Your site provided us with helpful info to work on. You’ve done an impressive task
    and our entire community will probably be thankful to you.

  8. Thanks for sharing your thoughts on website.

  9. Highly descriptive article, I enjoyed that a lot. Will there be a part 2?

  10. Every weekend i used to pay a quick visit this site, as i wish for enjoyment, since this this website conations in fact nice funny stuff too.

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *