【问题标题】:How to disabled Jump of the thirdpersoncontroller - Unity C#如何禁用第三人称控制器的跳转 - Unity C#
【发布时间】:2017-09-28 09:35:59
【问题描述】:

我有一个问题,我用 c# 统一制作了一个对话文本。好吧,我需要知道如何禁用第三人称控制器(统一的默认播放器)的跳跃,因为看不好。

像这样:

这是代码:

 

        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;
        }
    }

我试试

请帮助我,我不知道如何解决它。

谢谢!!

【问题讨论】:

  • 代码将位于游戏对象上的类之一中。你已经尝试过什么?
  • @Bejasc 我更新帖子给你看
  • 我已经为您提供了答案,但这确实是一个非常基本的问题。你读过这段代码吗?在此处发布问题之前,您应该努力并尝试自己解决问题,并在此处发布详细说明您已经尝试过的内容。

标签: c# unity3d dialog unity3d-unet


【解决方案1】:

要禁用跳跃,请删除触发它的代码。

Update() 中的这一行是触发玩家跳跃的原因。

m_Jump = CrossPlatformInputManager.GetButtonDown ("Jump");

【讨论】:

  • 非常感谢,但我需要这样的东西 m_Jump = CrossPlatformInputManager.GetButtonDown ("");但不起作用,对于禁用键盘的所有键,m_Jump = ("Jump") 再次激活但禁用键?
  • 我不明白你在问什么。要删除 Jump 功能(如您所要求的),您只需要删除该行。你必须在GetButtonDown() 中提供一些东西——如果你不想注册按钮按下,你为什么要编码GetButtonDown()??
猜你喜欢
  • 2021-05-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多