Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class DE10Controller : MonoBehaviour
- {
- [System.Serializable]
- public class Wheel
- {
- public List<Rigidbody> wheels;
- public float wheelMass = 600; // mass of each wheel pair without flange mass; i.e. twice the mass of 1 wheel without flange mass
- }
- public float targetVelocity; // target speed of rotation
- public float torque; // a torque to be applied to each wheel
- public Wheel wheel; // a group of setting related to wheels
- // Start is called before the first frame update
- void Start()
- {
- foreach(Rigidbody rb in wheel.wheels)
- {
- rb.mass = wheel.wheelMass;
- }
- }
- // Update is called once per frame
- void Update()
- {
- foreach (Rigidbody rb in wheel.wheels)
- {
- rb.mass = wheel.wheelMass;
- rb.AddTorque(0, 0, torque);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement