简体   繁体   English

第三人称角色不团结。

[英]3rd person character not moving in unity.

I have imported Unity Standard assets to Unity 5.6.0, I drag the 3rd person character to the scene, it keeps animating but it does not move on AWSD or Left/Right keys.我已将 Unity 标准资产导入 Unity 5.6.0,我将第三人称角色拖到场景中,它保持动画,但它不会在 AWSD 或左/右键上移动。 This is happening in only one project, it works on all other projects.这仅发生在一个项目中,它适用于所有其他项目。 I have searched from the net, but non of the solution seems to work.我从网上搜索过,但没有一个解决方案似乎有效。

只需尝试使用统一第三人称控制器重新导入资产,导入可能在某些地方出错,或者尝试在构建设置下构建游戏,看看是否有帮助

Your character controller is made up of multiple pieces (animation files/model/script and possibly other files).您的角色控制器由多个部分组成(动画文件/模型/脚本以及可能的其他文件)。 There could be a problem with how you are loading the 3rd person character to the scene.您如何将第三人称角色加载到场景中可能存在问题。 I would try creating a prefab of the 3rd person character within a project and then export it as a prefab.我会尝试在项目中创建第三人称角色的预制件,然后将其导出为预制件。 Could be missing the script attached to the object as well.也可能缺少附加到对象的脚本。 The prefab helps prevent you leaving any pieces behind that make up your character/objects.预制件有助于防止您留下构成角色/对象的任何碎片。 Helpful for level construction as well.也有助于关卡建设。

Take a look here if it helps: https://docs.unity3d.com/Manual/Prefabs.html如果有帮助,请看这里: https : //docs.unity3d.com/Manual/Prefabs.html

Another possible explanation could be how you have your input settings setup within that Unity Project.另一种可能的解释可能是您如何在该 Unity 项目中设置输入设置。 Try comparing the two inputs of the working instance, and the non-working instance.尝试比较工作实例和非工作实例的两个输入。

Try looking here for a more detailed approach : https://docs.unity3d.com/Manual/class-InputManager.html尝试在这里寻找更详细的方法: https : //docs.unity3d.com/Manual/class-InputManager.html

I had this problem too and in the end it was because I had my project set up to run on IOS in Build Settings.我也遇到了这个问题,最后是因为我在构建设置中将我的项目设置为在 IOS 上运行。 I Switched Platform to macOS and it worked.我将平台切换到 macOS 并且它起作用了。

Why?为什么? It seems that Unity's Virtual Controller expected the input to be from a Mobile Device (seems obvious now) and the CrossPlatformInputManager was not expecting WSAD.似乎 Unity 的虚拟控制器期望输入来自移动设备(现在似乎很明显),而 CrossPlatformInputManager 并不期望 WSAD。

A workaround in IOS mode is to edit the ThirdPersonCharacter/Scripts/ThirdPersonUserControl.cs and replace the ThirdPersonUserControl.cs with Input在IOS模式一种解决方法是编辑ThirdPersonCharacter /脚本/ ThirdPersonUserControl.cs并更换ThirdPersonUserControl.csInput

eg例如

// read inputs //float h = CrossPlatformInputManager.GetAxis("Horizontal"); //float v = CrossPlatformInputManager.GetAxis("Vertical"); // read inputs from default input float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical");

I found this when I was digging around an realised the Update function in the script was getting called, however CrossPlatformInputManager.GetAxis("Horizontal") was always returning 0.当我在挖掘脚本中的 Update 函数被调用时发现了这一点,但是CrossPlatformInputManager.GetAxis("Horizontal")总是返回 0。

It might be worth inspecting both at runtime.可能值得在运行时检查两者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM