Unity - 为角色控制器脚本 2D 的 'What Is Ground' 字段中不存在的平台新创建的图层
Unity - Newly created Layer for platforms not present in 'What Is Ground' field for Character Controller script 2D
我正在学习使用 Unity 创建 2D 游戏的基本教程。我熟悉 .Net/C#,但 Unity 和游戏开发对我来说比较陌生。
我创建了一些平台,希望角色(玩家)不会掉下去,而是能够继续行走、跳跃等等。
说明说要为这些平台创建一个新层,确保排序层不是玩家对象使用的层,然后 - 在角色控制器脚本 2D 中 - 将 'What is Ground' 的值设置为平台的排序层。
我能够毫无问题地创建新的排序图层,但是新创建的排序图层在 What Is Ground
字段中没有显示为可用图层?
我的新图层名为 foreground
,但是在 Unity 中似乎只有 default
图层可见?
查看截图:
我很确定你在谈论 this CharacterController2D tutorial。
他们在那里使用
public LayerMask whatIsGround;
这是一个LayerMask
. They are for Layers
not Sorting Layers
从你的问题描述来看,你似乎添加了一个SortingLayer
SortingLayer allows you to set the render order of multiple sprites easily. There is always a default SortingLayer named "Default" which all sprites are added to initially. Added more SortingLayers to easily control the order of rendering of groups of sprites. Layers can be ordered before or after the default layer.
而不是 Layer
Layers are most commonly used by Cameras to render only a part of the scene, and by Lights to illuminate only parts of the scene. But they can also be used by raycasting to selectively ignore colliders or to create collisions.
=> 确保添加 Layer
.
我正在学习使用 Unity 创建 2D 游戏的基本教程。我熟悉 .Net/C#,但 Unity 和游戏开发对我来说比较陌生。
我创建了一些平台,希望角色(玩家)不会掉下去,而是能够继续行走、跳跃等等。
说明说要为这些平台创建一个新层,确保排序层不是玩家对象使用的层,然后 - 在角色控制器脚本 2D 中 - 将 'What is Ground' 的值设置为平台的排序层。
我能够毫无问题地创建新的排序图层,但是新创建的排序图层在 What Is Ground
字段中没有显示为可用图层?
我的新图层名为 foreground
,但是在 Unity 中似乎只有 default
图层可见?
查看截图:
我很确定你在谈论 this CharacterController2D tutorial。
他们在那里使用
public LayerMask whatIsGround;
这是一个LayerMask
. They are for Layers
not Sorting Layers
从你的问题描述来看,你似乎添加了一个SortingLayer
SortingLayer allows you to set the render order of multiple sprites easily. There is always a default SortingLayer named "Default" which all sprites are added to initially. Added more SortingLayers to easily control the order of rendering of groups of sprites. Layers can be ordered before or after the default layer.
而不是 Layer
Layers are most commonly used by Cameras to render only a part of the scene, and by Lights to illuminate only parts of the scene. But they can also be used by raycasting to selectively ignore colliders or to create collisions.
=> 确保添加 Layer
.