返回介绍

HingeJoint.spring 弹力

发布于 2019-12-18 15:37:51 字数 2022 浏览 1065 评论 0 收藏 0

JavaScript => public var spring: JointSpring;
C# => public JointSpring spring;

Description 描述

The spring attempts to reach a target angle by adding spring and damping forces.

该弹力通过增加弹力和阻碍力尝试达到指定角度。

The JointSpring.spring force attempts to reach the target angle. A larger value makes the spring reach the target position faster.

该JointSpring.spring力尝试达到指定角度。一个大的值使该弹力装置更快达到指定位置。

The JointSpring.damper force dampens the angular velocity. A larger value makes the spring reach the goal slower.

JointSpring.damper阻碍角速度。一个大的值使该弹力装置更慢达到指定位置。

The spring reaches for the JointSpring.targetPosition angle in degrees relative to the rest angle. The rest angle between the bodies is always zero at the beginning of the simulation.

该弹力达到JointSpring.targetPosition角度相当于静止角度。在模拟开始时身体之间的关节静止角度总为0。

JavaScript:

#pragma strict
public class HingeExample extends MonoBehaviour {
	function Start() {
		var hinge: HingeJoint = GetComponent.<HingeJoint>();
		// This could be used to fire off a catapult.
		var hingeSpring: JointSpring = hinge.spring;
		hingeSpring.spring = 10;
		hingeSpring.damper = 3;
		hingeSpring.targetPosition = 70;
		hinge.spring = hingeSpring;
		hinge.useSpring = true;
	}
}

C#:

using UnityEngine;
using System.Collections;
 
 
public class HingeExample : MonoBehaviour {
	void Start() {
		HingeJoint hinge = GetComponent<HingeJoint>();
 
		// Make the spring reach shoot for a 70 degree angle.
		// This could be used to fire off a catapult.
 
		JointSpring hingeSpring = hinge.spring;
		hingeSpring.spring = 10;
		hingeSpring.damper = 3;
		hingeSpring.targetPosition = 70;
		hinge.spring = hingeSpring;
		hinge.useSpring = true;
	}
 
}

hingejoint

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

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

发布评论

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