Question by
j_pouya1999 · Jan 05, 2017 at 05:18 PM ·
jointswheelcolliderwheelwheel collidersuspension
save wheel Collider suspensionSpring targetPosition value
Hi i Want to save save wheelCollider suspensionSpring targetPosition value with regards to (CarID) please help me using System.Collections; using UnityEngine.UI; public class Fanar_setting : MonoBehaviour {
public float FrontV, RearV;
public Slider Fslide,Lslide;
public int CarID;
public _ImportFanar fanar;
void Update(){
CarID = PlayerPrefs.GetInt ("CarId");
fanar = FindObjectOfType<_ImportFanar> ();
FrontV = PlayerPrefs.GetFloat ("Fanar" + CarID.ToString ());
RearV = PlayerPrefs.GetFloat ("Fanar2" + CarID.ToString ());
}
public void Front(){
FrontV = Fslide.value;
JointSpring suspensionSpring = new JointSpring ();
suspensionSpring.spring = 35000f;
suspensionSpring.damper = 1500F;
suspensionSpring.targetPosition = FrontV;
fanar.FL.suspensionSpring = suspensionSpring;
fanar.FR.suspensionSpring = suspensionSpring;
PlayerPrefs.SetFloat ("Fanar" + CarID.ToString (), FrontV);
}
public void Rear(){
RearV = Lslide.value;
JointSpring suspensionSpring = new JointSpring ();
suspensionSpring.spring = 35000f;
suspensionSpring.damper = 1500F;
suspensionSpring.targetPosition = RearV;
fanar.RL.suspensionSpring = suspensionSpring;
fanar.RR.suspensionSpring = suspensionSpring;
PlayerPrefs.SetFloat ("Fanar2" + CarID.ToString (), RearV);
}
}
Comment
Your answer
Follow this Question
Related Questions
Wheel Colliders orientated incorrectly 0 Answers
Wheel Joint 2D motor + gravity 0 Answers
Vehicle drifting too much 0 Answers
Repositioning wheel collider through script 0 Answers
Wheel Collider violently shaking 2 Answers