![]() As can be seen in the expanded hierarchy of the rig prefab, one transform is rotated directly by the mouse and used to point towards a direction, while the camera transform smoothly looks in this direction using its own, separate rig. To get around this and emphasize the mouse's pointing ability, the camera and mouse control need to be separated. Examples of this style of control would be the Halo games or World of Warplanes. While this definitely does work, it can be a bit clumsy and make for some jarring camera movement depending on your game. The simplest way to accomplish this idea is to have an orbit camera that gets rotated by the mouse, crosshair in the middle of the screen, and then wherever the camera is pointed is where the plane flies. ![]() If you want to aim at something, just put the mouse cursor over it. If you want to fly towards something, you simply put the mouse cursor over it and the plane will fly towards it. ![]() What the control scheme in this project does is allow the player to use the mouse as a pointing device to fly the plane. While these can work, they don't take advantage of the mouse's greatest strength: as a pointing device. Most control schemes involve using the mouse as a substitute for a joystick or otherwise directly controlling the aircraft. The mouse is not an ideal method of controlling an aircraft. An extremely simple HUD is also included to demonstrate how it's supposed to work. To give an example of how you might do this, the demo includes a very simple Rigidbody based airplane with the steering behaviors necessary to fly itself. How your aircraft actually flies towards that point is an implementation detail specific to your project and will require scripting. The camera rig only handles telling where the aircraft is meant to fly. Use the MouseFlightController.MouseAimPos and MouseFlightController.BoresightPos C# properties to draw HUD elements for the mouse cursor and aircraft's direction respectively.In code, use the MouseFlightController.MouseAimPos C# property to get the world postion the mouse cursor is pointing to.Assign your vehicle's transform to the Aircraft property in the MouseFlightController's Inspector.Drop the MouseFlightRig prefab into your scene.The core of this project is the MouseFlightController component and the MouseFlightRig prefab. Sometimes you might want to manually control the pitch or roll for a maneuver, so a couple keyboard overrides exist. The plane will automatically try to fly towards the crosshair. The circle is controlled by the mouse, while the crosshair shows where the plane is pointed. To fly the demo plane, simply move the mouse around. You can either clone the repository or download the asset package located in the root. (Open Window->Lighting->Settings, then click the gear icon on the top right -> Reset.) Download Note: When importing the package into 5.6.4, the demo scene will need to have its lighting reset. This project was built in Unity 2017.3.1f1, and tested in 2018.3.0 and 5.6.4. It is in my opinion the single best and most robust system for controlling aircraft, especially those with more realistic physics. If you want to switch between the settings occasionally, you just select which control file you want to use.This project is an example of mouse controls for aircraft based on the excellent system used by Gaijin's War Thunder. If you find you don't like your current set up, you can just go back to your previous settings by using the "Import" function to use your older settings. Bind your air controls to your Joystick then bind your ground controls to your mouse & keyboard through the Setup Wizard.Īfter that's done, make a separate Export copy of the controls you just set up. You'll see an option to set up Air or Ground. Second: Proceed through the setup Wizard for your joystick. You should always make copies of your control set ups as it makes it 1,000x easier than having to rebind everything constantly if you want to go back to a previous control set up. You'll need to manually set it all up (the annoying part).įirst: Export a copy of your current control settings and save it on your Desktop (or place of your choosing). ![]() It's very simple, but also very annoying.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |