Need help with controling my vehicle's flight with the mouse

Ok i have never done anything in 3d. I only made a 3d pacman game with blitz3D a while ago. So this is probably my biggest problem with making my game. It is a space combat game where you can explore th galaxy and colonize planets and fight other corporations and aliens. I have done it in 2d and it was fun, but i could do a whole lot more with it in 3d.

So my problem is i would like to (and i wont give up until i do) have a flying system where the ship is controlled by the mouse. It is much more effective for my type of game rather then the arrow keys or the num-pad. If you dont know what i mean take a look at the game called air-rivals. (maybe youtube video would help too)

I want a little crosshair in the centre of the screen and when the mouse is in the middle you fly forward and when you move the mouse left of the crosshair it moves left.

Is there a sample game with this that i can look at? One of my problems is taking the player’s angle and turning it into it’s direction. Of course, this is hard because there is 3 dimensions instead of two.

I know its alot of work but i am willing to learn and it would be great if somone could point out something that could help me accomplish this.

Thank you :bulb:

This sounds a lot like mouse warping.
I’m not sure how to do this, but Akuryou’s flight game implements something similar.

This is, I believe, what I did in a recent project of mine; it might not be the best method, but I found it to work for me.

(Indentation edited and annotations added)

Taken from the update task:

if base.mouseWatcherNode.hasMouse():
    #get the current mouse position
    mouse_x = base.mouseWatcherNode.getMouseX()
    mouse_y = base.mouseWatcherNode.getMouseY()

    cursorPos = Vec2(mouse_x, mouse_y)
    cursorPosLength = cursorPos.length()

    #Displaying a targeting cursor and line
    cursorRadius = (Vec2(self.cursorHalfWidth, self.cursorHalfHeight)).length()/2
    self.cursor.setPos(mouse_x-self.cursorHalfWidth, 0, mouse_y-self.cursorHalfHeight)
    self.lineManipulator.setR(math.degrees(math.atan2(mouse_x, mouse_y)))
    if cursorPosLength > cursorRadius:
        self.line.setSz(cursorPosLength-cursorRadius+0.01)
    else:
        self.line.setSz(0)

    #I only allowed turns when the mouse was outside
    # of a small radius, so that the movement wasn't
    # over-sensitive to my sense
    if cursorPosLength > MIN_CURSOR_OFFSET_FOR_TURN:
        cursorPos.normalize()
        cursorPos *= (cursorPosLength-MIN_CURSOR_OFFSET_FOR_TURN)

        #The actual turning...
        if cursorPos.getY() != 0:
            self.player.turnUpDown(cursorPos.getY()*MAX_ROTATION*dt)
        if cursorPos.getX() != 0:
            self.player.turnLeftRight(-cursorPos.getX()*MAX_ROTATION*dt)

From my “Player” class:

def turnLeftRight(self, angle):

    rotQuat = self.manipulator.getQuat()
    up = rotQuat.getUp()
    up.normalize()
    turn = Quat()
    turn.setFromAxisAngle(angle, up)
    self.manipulator.setQuat(rotQuat * turn)
    
def turnUpDown(self, angle):
    #Get the current right vector, use that to create
    # a "turn" quaternion, and then apply it
    rotQuat = self.manipulator.getQuat()
    right = rotQuat.getRight()
    right.normalize()
    turn = Quat()
    turn.setFromAxisAngle(angle, right)
    self.manipulator.setQuat(rotQuat * turn)