- Home /
Question by
el-mas-pro-470 · Nov 10, 2018 at 02:15 AM ·
wheelcollidercar physics
change wheel collider with script?
Hello! I ask you something, does anyone know how to change the "forward stiffness factor" by pressing a key? I'm using Csharp. Thank you! Here the script (With errors):
using UnityEngine;
using System.Collections;
public class Brake : MonoBehaviour {
public WheelCollider ruedaTI;
public WheelCollider ruedaTD;
// Use this for initialization
void Start()
{
ruedaTI = GetComponent<WheelCollider>();
ruedaTD = GetComponent<WheelCollider>();
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.Space))
WheelFrictionCurve fFriction = ruedaTI.forwardFriction;
fFriction.stiffness = 0f;
WheelFrictionCurve fFriction = ruedaTD.forwardFriction;
fFriction.stiffness = 0f;
if (Input.GetKeyUp(KeyCode.Space))
WheelFrictionCurve fFriction = ruedaTI.forwardFriction;
fFriction.stiffness = 0.75f;
WheelFrictionCurve fFriction = ruedaTD.forwardFriction;
fFriction.stiffness = 0.75f;
}
}
Comment
Your answer
Follow this Question
Related Questions
Car Colliders fall off car 2 Answers
What is the WheelDampingRate property from WheelCollider? 0 Answers
How to automatically stop car when fuel ends up ? 2 Answers
WheelCollider: Two Cars- Speed Problem 0 Answers
WheelCollider Problem 1 Answer