WheelCollider组件

原创
2016/05/24 21:20
阅读数 1.9K

该组件是用来描述轮胎的(比如扭矩 转速等等),可用来附加在赛车游戏 的车轮上

A special collider for vehicle wheels.

Wheel collider is used to model vehicle wheels. It simulates a spring and damper suspension setup, and uses a slip based tire friction model to calculate wheel contact forces.

Wheel's collision detection is performed by casting a ray from center downwards the local y-axis. The wheel has a radius and can extend downwards by suspensionDistance amount.

The wheel is controlled with motorTorque, brakeTorque and steerAngle properties.

Wheel collider computes friction separately from the rest of physics engine, using a slip based friction model. This allows for more realistic behaviour, but makes wheel colliders ignore standard PhysicMaterial settings. Simulation of different road materials is done by changing the forwardFriction and sidewaysFriction based on what material the wheel is hitting. See Also: GetGroundHit and WheelFrictionCurve.           -----------------------来自 Scripting API

 

3个  应用例子

1.通过扭矩来使车加速   

GetComponent<WheelCollider>().motorTorque = Input.GetAxis("Vertical") * 25000 * Time.deltaTime;

2.通过steer 来控制汽车转弯

float delta=  Input.GetAxis("Horizontal");
GetComponent<WheelCollider>().steerAngle = 20 * delta;

3.通过localRotation控制汽车转弯

float delta=  Input.GetAxis("Horizontal");
transform.localRotation = Quaternion.Euler(transform.localRotation.x, 30 * delta, 0);

 

 

展开阅读全文
2
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
2
分享
返回顶部
顶部