如何禁用第三人称控制器的跳转 - Unity C#
How to disabled Jump of the thirdpersoncontroller - Unity C#
我有一个问题,我用 c# 统一制作了一个对话文本。好吧,我需要知道如何禁用 thirdpersoncontroller(unity 的默认播放器)的跳跃,因为它看起来不太好。
像这样:
这是代码:
private void Update()
{
if (!m_Jump) {
m_Jump = CrossPlatformInputManager.GetButtonDown ("Jump");
}
}
// Fixed update is called in sync with physics
private void FixedUpdate()
{
// read inputs
float h = CrossPlatformInputManager.GetAxis("Horizontal");
float v = CrossPlatformInputManager.GetAxis("Vertical");
bool crouch = Input.GetKey(KeyCode.C);
// calculate move direction to pass to character
if (m_Cam != null)
{
// calculate camera relative direction to move:
m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized;
m_Move = v*m_CamForward + h*m_Cam.right;
}
else
{
// we use world-relative directions in the case of no main camera
m_Move = v*Vector3.forward + h*Vector3.right;
}
#if !MOBILE_INPUT
// walk speed multiplier
if (Input.GetKey(KeyCode.LeftShift)) m_Move *= 0.5f;
#endif
// pass all parameters to the character control script
m_Character.Move(m_Move, crouch, m_Jump);
m_Jump = false;
}
}
我试试
请帮帮我,我不知道怎么解决。
谢谢!!
要禁用跳跃,删除触发它的代码。
Update()
中的这一行是触发玩家跳跃的内容。
m_Jump = CrossPlatformInputManager.GetButtonDown ("Jump");
我有一个问题,我用 c# 统一制作了一个对话文本。好吧,我需要知道如何禁用 thirdpersoncontroller(unity 的默认播放器)的跳跃,因为它看起来不太好。
像这样:
这是代码:
private void Update()
{
if (!m_Jump) {
m_Jump = CrossPlatformInputManager.GetButtonDown ("Jump");
}
}
// Fixed update is called in sync with physics
private void FixedUpdate()
{
// read inputs
float h = CrossPlatformInputManager.GetAxis("Horizontal");
float v = CrossPlatformInputManager.GetAxis("Vertical");
bool crouch = Input.GetKey(KeyCode.C);
// calculate move direction to pass to character
if (m_Cam != null)
{
// calculate camera relative direction to move:
m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized;
m_Move = v*m_CamForward + h*m_Cam.right;
}
else
{
// we use world-relative directions in the case of no main camera
m_Move = v*Vector3.forward + h*Vector3.right;
}
#if !MOBILE_INPUT
// walk speed multiplier
if (Input.GetKey(KeyCode.LeftShift)) m_Move *= 0.5f;
#endif
// pass all parameters to the character control script
m_Character.Move(m_Move, crouch, m_Jump);
m_Jump = false;
}
}
我试试
请帮帮我,我不知道怎么解决。
谢谢!!
要禁用跳跃,删除触发它的代码。
Update()
中的这一行是触发玩家跳跃的内容。
m_Jump = CrossPlatformInputManager.GetButtonDown ("Jump");