Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class DE10Controller : MonoBehaviour
  6. {
  7. [System.Serializable]
  8. public class Wheel
  9. {
  10. public List<Rigidbody> wheels;
  11. public float wheelMass = 600; // mass of each wheel pair without flange mass; i.e. twice the mass of 1 wheel without flange mass
  12. }
  13.  
  14.  
  15. public float targetVelocity; // target speed of rotation
  16. public float torque; // a torque to be applied to each wheel
  17. public Wheel wheel; // a group of setting related to wheels
  18.  
  19. // Start is called before the first frame update
  20. void Start()
  21. {
  22. foreach(Rigidbody rb in wheel.wheels)
  23. {
  24. rb.mass = wheel.wheelMass;
  25. }
  26. }
  27.  
  28. // Update is called once per frame
  29. void Update()
  30. {
  31. foreach (Rigidbody rb in wheel.wheels)
  32. {
  33. rb.mass = wheel.wheelMass;
  34. rb.AddTorque(0, 0, torque);
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement