ArcadeSpaceFlightExample | Simple example of arcade style space sim flight | Game Engine library
kandi X-RAY | ArcadeSpaceFlightExample Summary
kandi X-RAY | ArcadeSpaceFlightExample Summary
Simple example of arcade style space sim flight physics.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ArcadeSpaceFlightExample
ArcadeSpaceFlightExample Key Features
ArcadeSpaceFlightExample Examples and Code Snippets
Community Discussions
Trending Discussions on ArcadeSpaceFlightExample
QUESTION
I am creating a game that is set in Zero-gravity. I am using a script that can be found here https://github.com/brihernandez/ArcadeSpaceFlightExample
The movement is controlled by a throttle that can be increased/decreased using the mouse wheel or 'w' and 's' keys.
This code controls the mouse wheel and is the same for the 'w' and 's' keys.
...ANSWER
Answered 2020-Sep-04 at 10:15The object that is accelerated by the throttle stops moving when I decrease the throttle and does not drift or continue moving as it should in zero gravity.
The Rigidbody component has properties that can be changed in the Inspector (documented here) (and also via script (documented here)):
- Mass: The mass of the object (in kilograms by default).
- Drag: How much air resistance affects the object when moving from forces. 0 means no air resistance, and infinity makes the object stop moving immediately.
It sounds like your Drag value might be too large (?).
Although this example project uses "space mechanics" (effectively with no air resistance), the Drag property can still be used to tune the movement and "drift behavior" of the rigidbody, and to control how long it will keep decelerating after the throttle value went down to 0.
Alternatively, you could try to experiment with other ForceMode parameters for the Add*Force() calls: ForceMode.Acceleration or ForceMode.VelocityChange (which is ignoring the mass of the rigidbody).
To make your game more "realistic", you could instead set the Drag property to 0 (no air resistance like in real space -> infinite drift), and try to actively decelerate the ship by experimenting with retrograde rockets/thrusters, by adding a force in backward direction. However, that's probably quite impractical for an arcade game, I guess.
There are also the global Physics settings of the project, which can be found under Edit -> Project settings -> Physics (documented here). There, you'll also find many important physics settings (like Gravity, for example).
(It can also be interesting to have a look at the official docs of the PhysX physics engine, which Unity uses internally for its 3D physics, to understand how things actually work under the hood...)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ArcadeSpaceFlightExample
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page