3D 平台游戏中玩家角色的良好碰撞表现?

发布于 2024-07-26 08:21:03 字数 333 浏览 3 评论 0原文

我正在尝试制作一个简单的 3D 平台游戏。 我遇到的问题是碰撞检测和响应。 我目前用一个球体代表我的玩家角色(用于墙壁和地板碰撞)。

我使用简单的重力和方向力,使用箭头键进行移动。

当我走到边缘(比如悬崖)时,我的问题就出现了。 我像球一样滑过边缘,但我正在寻找的行为是像直立的圆柱体一样从边缘掉下来。 布尔值“我在平台上,或者我不在平台上”,而不是“我正在逐渐滑出边缘”。

使用直立圆柱体的问题在于,自动滑上楼梯变得不可能,并且当沿着任何类型的斜坡行走时,圆柱体必须仅通过一个边缘接触,或者部分嵌入斜坡中。

3D 平台游戏中玩家角色的良好碰撞表示是什么?

I am trying to make a simple 3d platform game. The issue I'm having is with the collision detection and response. I am currently representing my player character (for wall and floor collisions) with a sphere.

I employ a simple gravity force and directional forces using the arrow keys for movement.

My problem occurs when I come to an edge (like a cliff). I slide over the edge like a ball would, but the behaviour I'm looking for is to fall off the edge like an upright cylinder. A boolean "I am on the platform, or I am not on the platform", and not "I'm sliding off the edge gradually".

The problem with using an upright cylinder is that sliding up stairs automatically becomes impossible, and when walking along any kind of slope, the cylinder must either touch only by one edge, or be partially embedded in the slope.

What is a good collision representation of the player character in a 3d platform game?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

2024-08-02 08:21:04

尝试使用扁椭球体。 只需沿垂直轴拉伸球体即可。

Try an oblate ellipsoid. Just stretch the sphere along the vertical axis.

清君侧 2024-08-02 08:21:04

听起来您的理想解决方案是带有圆形边缘的直立圆柱体。 它仍然会从直边上翻倒,但圆边可以让你滑上楼梯。 您可能必须使用舍入半径才能获得您想要的效果。

It sounds like your ideal solution would be an upright cylinder with rounded edges. It would still tip over straight edges, but the rounded edges would allow you to slide up stairs. You may have to play with the rounding radius in order to get the effect that you want.

亢潮 2024-08-02 08:21:03

您可以保留球体用于碰撞检测。

如果发现碰撞,那么您应该通过将角色划分为多个组件来更准确地计算碰撞。

一种常见的解决方案是使用球体(因为碰撞很容易计算)作为头部、躯干,使用圆柱体作为腿和手臂(您还可以为手和脚添加球体)。

您有机会阅读这本书吗?

You may keep the sphere for the collision detection.

And if you find collision, then you should compute more accurately for collision, by dividing your character into several components.

One common solution is to used sphere (because the collision is easy to compute) for the head, the trunk, and a cylinder for the legs and the arms (you can also add sphere for the hands and feet).

Do you have the possibility to read this book ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文