Jump to content
  • Advertisement
Sign in to follow this  
psy_commando

Trying to control an aircraft with the mouse cursor

This topic is 2170 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!