1 using System;
2 using UnityEngine;
3
4 namespace UnityStandardAssets.Vehicles.Car
5 {
6 // this script is specific to the car supplied in the the assets
7 // it controls the suspension hub to make it move with the wheel are it goes over bumps
8 public class Suspension : MonoBehaviour
9 {
10 public GameObject wheel; // The wheel that the script needs to referencing to get the postion for the suspension
11
12
13 private Vector3 m_TargetOriginalPosition;
14 private Vector3 m_Origin;
15
16
17 private void Start()
18 {
19 m_TargetOriginalPosition = wheel.transform.localPosition;
20 m_Origin = transform.localPosition;
21 }
22
23
24 private void Update()
25 {
26 transform.localPosition = m_Origin + (wheel.transform.localPosition - m_TargetOriginalPosition);
27 }
28 }
29 }
2 using UnityEngine;
3
4 namespace UnityStandardAssets.Vehicles.Car
5 {
6 // this script is specific to the car supplied in the the assets
7 // it controls the suspension hub to make it move with the wheel are it goes over bumps
8 public class Suspension : MonoBehaviour
9 {
10 public GameObject wheel; // The wheel that the script needs to referencing to get the postion for the suspension
11
12
13 private Vector3 m_TargetOriginalPosition;
14 private Vector3 m_Origin;
15
16
17 private void Start()
18 {
19 m_TargetOriginalPosition = wheel.transform.localPosition;
20 m_Origin = transform.localPosition;
21 }
22
23
24 private void Update()
25 {
26 transform.localPosition = m_Origin + (wheel.transform.localPosition - m_TargetOriginalPosition);
27 }
28 }
29 }