Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question What is the closest method of movement to X-Wing and TIE Fighter games?

Discussion in 'Physics' started by DCTShinobi, Jul 1, 2023.

  1. DCTShinobi

    DCTShinobi

    Joined:
    Jun 23, 2014
    Posts:
    51
    I'm trying to make a starfighter game with movement/control similar to the old X-Wing and TIE Fighter series. When I started my project, I was using Transform.Translate/Rotate to move a ship. But I recently learned about Rigidbody.Move, so I adjusted my code to use it. Also, I was using kinematic rigidbodies, but I noticed they did not trigger collisions, so I made them non-kinematic.

    However, I've been reading that a non-kinematic rigidbodies using RigidBody.Move in 3D will not interpolate, so it may cause issues down the line.

    I have been using the Translate/Move methods because I really want to have absolute control over a starfighter's movement during normal flight. I've managed to also simulate momentum/drift based on defined variables. The movement itself seems to work very well.

    I know that AddForce/AddTorque is recommended for dynamic rigidbodies, but I really don't know how to maintain the desired amount of control with those methods. I've read things about manually setting the rigidbody's velocity, but that it's not recommended for whatever reasons.

    So what would be the best method for me to use? The way my movement is working now is great... I just need the rigidbody to register collisions (I assume with interpolation so objects won't teleport through each other), and also to allow the physics engine to function if a collision does happen (perhaps overriding or adding to the Move command).

    Thank you! :)

    P.S. For an example of why I want strict control over movement, I want a starfighter to be able to reach and maintain a desired speed without going above or below it... again, like the old X-Wing/TIE games. Unfortunately, I've had no success attempting to replicate those games' control and movement by manipulating AddForce, velocity, and drag. I just can't get a ship to hit or maintain desired speeds precisely, let alone getting the desired acceleration and deceleration rates on top of it.
     
  2. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    453
    Switch off gravity, use AddForce/AddTorque, and add drag/angularDrag to your rigidbody if you need.