Skip to main content
GameDev.net gamedev.net
🔒 Locked

Trying to control an aircraft with the mouse cursor

Started by psy_commando Aug 3, 2012 at 5:15 PM 2 replies 1.5k views
Original Post
psy_commando
psy_commando
Hi, I'm making a 3D aircraft railshooter based on Starfox, and I'm having trouble. I don't really know what would be the best way to get the aircraft up/down left/right movement controlled by mouse cursor movement. Basically, I want the aircraft to follow smoothly the cursor, and turn towards it, so the shooting position matches the cursor.

I tried a few thing but it didn't work properly.
First,I calculated 2 ratios between the mouse position and the screen size, Xratio and Yratio. I then computed the bounds of movement of the aircraft, and calculated the target position multiplying the width and height of the bounds to the corresponding ratios. This gave me coordinates that I used to place the aircraft in the world. However, the crosshairs didn't match the firing position with this approach, and it was kinda inacurrate for aiming.
Then I tried to convert 2D screen mouse cursor position to 3D space position. However, since the "camera lens" is tiny, the mouse wouldn't make the aircraft move much from its default position, and it wouldn't cover most of the moveable area !

At this point any suggestion is welcome !
psy_commando
psy_commando
I'm still stuck on this. Can someone at least give me some pointers or a lead to find the solution ?
Waterlimon
Waterlimon
project the mouse pos on screen onto a plane somewhere in front of the aircraft, then make the aircraft point towards that point? The aircraft should fire towards that point...
o3o
psy_commando
psy_commando

project the mouse pos on screen onto a plane somewhere in front of the aircraft, then make the aircraft point towards that point? The aircraft should fire towards that point...

Thanks, but I already did that. The problem, is that the "screen" in worldspace is tiny, and moving the mouse to the top of the screen will only make the aircraft move 0.1 unit up. It won't ever move to the top of the screen. I don't know if you understand what I mean, I'm not sure how to explain it correctly.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.