百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

ArcadeSpaceFlightExample

> 编程语言
开源

一个简单的街机风格的太空模拟飞行物理示例。

99 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个简单的街机风格的太空模拟飞行物理示例。

Arcade Space Flight Physics Example

Simple example of arcade style space sim flight physics. Built with Unity 5.6.

Download

You can either clone the repository, or download either the demo or asset package from the releases page.

Controls

There are two control modes supported. The first is mouse flight and the second is traditional. They can be toggled by checking the "Use Mouse Input" property on the ShipInput component.

Mouse Controls

  • W/S: Increase/Decrease throttle
  • A/D: Strafe Left/Right
  • Mouse scrollwheel: Increase/Decrease throttle
  • Mouse motion: Pitch/Yaw

Traditional Controls

  • W/S: Pitch Down/Up
  • A/D: Yaw Left/Right
  • R/T: Increase/Decrease throttle

Note that with the traditional control setting, a gamepad or joystick's X/Y axes can be used for flight as well.

Component Organization

When possible, I like to break things off into very self-contained components. This isn't always possible, but I feel it's a good practice in general that keeps your source files small and easily understood. However, this does add some complexity in that it requires you to link components together in some way.

Personally, I prefer doing these associations in code, especially when the components are likely to be on the same GameObject. In the case of the ship, it's made of three different components: Ship, Input, and Physics. The way I configured it here, the Ship component is meant to represent the entire ship. All external access to ship properties such as velocity or input are meant to go through the ship. In an effort to keep individual components as dumb as possible, and to minimize cross-component dependency, they communicate (only if necessary) to the ship, rather than other components directly. While there isn't an example of this in the project, each component has a reference to the ship just in case. The ship itself also passes information between components as needed.

There are advantages and disadvantages to this method, but I think it's worth showing as an example of one way to tackle complex component interaction.

Ship

As mentioned above, the ship component represents the ship as a whole and provides a communication mechanism between components.

Ship Input

In keeping with the mentality of separating out responsibilities, this component handles all input. In this example, only player input is considered, but it would be trivial to add a flag here to ignore player input if this isn't the player (by checking ship.isPlayer). A great use case for this would be if you want an AI to instead drive the input. Having an input layer between the player/AI, and the ship itself, allows the ship to only care about ship input and not where it's coming from.

Ship Physics

This component is taken almost verbatim from my UnityCommon repository. It's a generic space physics component that can apply forces and torques to a rigidbody using inputs that a ship's input would give. You give it the forces that it can apply in each axis, and then how much of those forces to apply.

Changelog

1.0 08/24/2017

  • Initial commit

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言