Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

Make gradual acceleration with drag.

$
0
0
Im making a top-down game where you control a spaceship. Your spaceship has a rigidbody and with W/S you increase/decrease the thrust (from 0 to 1) and every fixedupdate i do this: rb.AddForce (transform.forward * shipStats.acceleration*thrust); Im also forced to use at least a drag of 0.7 because i dont want the ships to "slide" when you turn (they work more like an atmospheric fighter than a spaceship). The problem comes with the big spaceships, if i put a low enough acceleration so that it slowly increases its speed and doesnt reach max speed in 1 second, it wont ever reach max speed because of the drag. If i give it a high enough acceleration so that it can overcome drag and reach max speed, it will just reach it in 1 sec. I've thought about making each ship modify the "thrust" value at different rates, for example fighters give thrust +0.1 when you press "W" and big ones only give +0.01 so that they take longer to reach max thrust and therefore seem like they slowly accelerate but i feel like there might be an easier way. TLDR: I have a rigidbody with max speed of 50 and drag of 0.7. Atm if i give it enough "addforce" to be able to reach max speed, it gets to it in just 1 second, but if i lower the addforce value it wont ever reach it cause of the drag. Is there a simple way to make addforce ignore drag at high speed while still keeping drag to not slide on turns?

Viewing all articles
Browse latest Browse all 1264


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>