Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by NickCh · Jan 06, 2011 at 02:43 PM · movementcharacter

Need help with char movement.

Hi guys.Im trying out to make a game with Aircrafts.So here is the thing...I wanna make my charachter to rotate with the mouse (Well i did that thanks to mouse look :D) but when for example the user has moved the mouse on Y direction...the aircraft to rotate there and go straight to that direction.(again:rotation made with mouse look)

I tried transform.position and direction and other things but i CAN'T!

Can you help me please? :)

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Justin Warner · Jan 06, 2011 at 03:47 PM 0
Share

Can you not use the WASD to move the aircraft and the mouse look to rotate around?

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Statement · Jan 06, 2011 at 08:03 PM

If I understood your question, here's a simple aircraft script.

public class Aircraft : MonoBehaviour { public float flightSpeed = 1.0f; public float yawSpeed = 250.0f; public float pitchSpeed = 250.0f;

 void Update()
 {
     float time = Time.deltaTime;
     float yaw = Input.GetAxis("Mouse X") * yawSpeed * time;
     float pitch = Input.GetAxis("Mouse Y") * pitchSpeed * time;

     transform.Rotate(Vector3.left, -pitch);
     transform.Rotate(Vector3.forward, -yaw);
     transform.Translate(Vector3.forward * flightSpeed * time);
 }

}

You probably want to change flightSpeed a bit in case you find the motion too slow. It should be attached to a camera. It uses mouse controls to fly sort of like an airplane.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image NickCh · Jan 07, 2011 at 07:46 PM 0
Share

It is full of errors.Its C# script right?But in .js is also full of errors...Where did you find the script?

avatar image NickCh · Jan 07, 2011 at 07:54 PM 0
Share

WAIT i fixed the errors and its almost what i want!!! Thanks you have me one step further from my goal!!!

avatar image Statement · Jan 07, 2011 at 09:04 PM 0
Share

Further? :( I hoped to bring you closer.

avatar image NickCh · Dec 29, 2012 at 01:34 AM 0
Share

lol was checking out my questions. yea closer :p

avatar image
1

Answer by The_r0nin · Jan 06, 2011 at 04:23 PM

I'll refer you to my thread on this issue to help get you started: Click Here.

I never got a satisfactory answer, so hopefully you can take the solution a step farther. I ended up abandoning this approach and went with an approach that rotates the aircraft based on whether the mouse is to the right/left of the center of the screen and applies pitch based on whether the mouse is above/below the center. If you are interested, I'll post some of that code here when I get the chance...

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Basic Character Transform with Joystick 1 Answer

Character movement range in strategy game. 2 Answers

Why am I not moving forward? 1 Answer

Third Person type Rpg movement 0 Answers

Why is Character just moving "smooth" when camera follows? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges