返回介绍

WheelFrictionCurve.stiffness 刚度

发布于 2019-12-18 15:38:46 字数 2444 浏览 1030 评论 0 收藏 0

JavaScript => public var stiffness: float;
C# => public float stiffness;

Description 描述

Multiplier for the extremumValue and asymptoteValue values (default 1).

用于extremumValue和asymptoteValue值的倍数(默认为1)。

Changes the stiffness of the friction. Setting this to zero will completely disable all friction from the wheel.

改变摩擦的刚度,设置为零将完全禁用车轮的所有摩擦。

Usually you modify stiffness to simulate various ground materials (e.g. lower the stiffness when driving on grass). See Also: WheelCollider.GetGroundHit.

通常修改stiffness来模拟各种地面材质(例如,草地具有较低的刚度)。

JavaScript:

#pragma strict
public var wheel: WheelCollider;
function Start() {
	wheel = GetComponent.<WheelCollider>();
}
// static friction of the ground material.
function FixedUpdate() {
	var hit: WheelHit;
	if (wheel.GetGroundHit(hit)) {
		var fFriction: WheelFrictionCurve = wheel.forwardFriction;
		fFriction.stiffness = hit.collider.material.staticFriction;
		wheel.forwardFriction = fFriction;
		var sFriction: WheelFrictionCurve = wheel.sidewaysFriction;
		sFriction.stiffness = hit.collider.material.staticFriction;
		wheel.sidewaysFriction = sFriction;
	}
}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    public WheelCollider wheel;
 
    void Start() {
        wheel = GetComponent<WheelCollider>();
    }
 
    // When attached to the WheelCollider, modifies tire friction based on
    // static friction of the ground material.
    void FixedUpdate() {
        WheelHit hit;
        if (wheel.GetGroundHit(out hit)) {
        	WheelFrictionCurve fFriction = wheel.forwardFriction;
            fFriction.stiffness = hit.collider.material.staticFriction;
            wheel.forwardFriction = fFriction;
            WheelFrictionCurve sFriction = wheel.sidewaysFriction;
            sFriction.stiffness = hit.collider.material.staticFriction;
            wheel.sidewaysFriction = sFriction;
        }
    }
}

WheelFrictionCurve

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文