Sign in to follow this  
psy_commando

Trying to control an aircraft with the mouse cursor

Recommended Posts

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 !

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
[quote name='Waterlimon' timestamp='1344627669' post='4968183']
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...
[/quote]
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this