Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Spaceship rotation

Discussion in 'Getting Started' started by alex119, Dec 15, 2015.

  1. alex119

    alex119

    Joined:
    Dec 10, 2015
    Posts:
    7
    Hello,

    I'm trying to make a spaceship flying around like in Freelancer game.But I don't know how to make the spaceship and camera to rotate after the cursor.Some suggestion or some clues ?

    THank you!
     
  2. DugelStudios

    DugelStudios

    Joined:
    Feb 21, 2015
    Posts:
    92
    This thread is in the wrong topic and will most likely be moved.

    Also, it seems like you lack basic understanding of Unity. But that is to be expected because you've had Unity for less than a week according to your joined date... I'd recommend stop trying to build this game that your building and do some basic tutorials on Udemy, youtube, or the projects in the learn section on this website. After you do a couple of those go back to this problem and it may seem obvious to you. Good luck!
     
    ChrisSch likes this.
  3. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Aurore is coming for you. :D
     
  4. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    We can actually call @Aurore :D
     
    ChrisSch likes this.
  5. alex119

    alex119

    Joined:
    Dec 10, 2015
    Posts:
    7
    Yash and Chris you better go and do something useful.
     
  6. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    I know I should but I'm feeling lazy...
     
  7. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
  8. alex119

    alex119

    Joined:
    Dec 10, 2015
    Posts:
    7
    Thank you ostwind. Sorry for the thread, but the problem is that I had a while ago Unity, like 2 years ago, but I gave up because I didn't have a good laptop.So I thought that I could succeded without the tutorials. :)
     
  9. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,554
    Unproject mouse cursor position.
    That'll give you direction in which ship wants to move (assuming ship is at the center of the screen).
    Acos of dot product between ship's (normalized) forward vector and that (normalized) direction will give you rotation angle.
    (normalzied) cross product between ship's forward vector and that direction will give you rotation axis.
    Combine both, you'll get yourself either quaternion or rotation matrix which then can be applied to object's Transform component.

    Adjust the angle for ship's maxmum turning speed first, though, so rotation won't be instant.