今天依旧是坦克项目
本来想试试wheelCollider来做移动的,直到我看了这个视频:
How to make Simple Tank Controller + Camera Controller | Unity Tutorial
应该是个老外做的,看的出来他很熟练,但是效果很不怎么样。。
其实仔细想想,战争雷霆那么真实的一个游戏,我真的喜欢他的操作手感吗?
其实我只需要有物理,然后移动不要那么僵硬,不要一点加减速的感觉都没有就行了。。。
物理效果还是得靠刚体和碰撞器,但是加减速。。。
我看了看移动的实现
transform.Translate(new Vector3(0f, 0f, moveSpeed) * Time.deltaTime);
其中moveSpeed是个不变的值,用这个直接移动确实不行。
其实我早想到了,用GetAxis就有那种效果了。
但是我绕了点弯路,我找到了以前做的Unity官方提供的tank项目
从这个项目说不定我能学点东西
private void Move ()
{
// Create a vector in the direction the tank is facing with a magnitude based on the input, speed and the time between frames.
Vector3 movement = transform.forward * m_MovementInputValue * m_Speed * Time.deltaTime;
// Apply this movement to the rigidbody's position.
m_Rigidbody.MovePosition(m_Rigidbody.position + movement);
}
private void Turn ()
{
// Determine the number of degrees to be turned based on the input, speed and time between frames.
float turn = m_TurnInputValue * m_TurnSpeed * Time.deltaTime