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
0
Question by RMBL21 · Jan 09, 2015 at 08:13 AM · rotationtransformaxis

Problem changing rotation of 3rd Person Controller

Hi,

Im new to Unity and i've been messing around with it for a while and i have encountered the following problem.

I used a 3rd person controller to create a ship that navigates through the scene just like if it was a character standing but in this case theres no gravity and the ship can move on the Y axis (it is able to go up and down)

The issue that im having right now is that, whenever the ship goes up (movement on Y axis) it basically "floats up".

Instead of this i'd like to have it be able to pitch up/down just like a plane.

alt text

The first thing I tried was adding the following code to the 3rd person controller to see if it would pitch up.

 transform.Rotate(Vector3.left * Time.deltaTime);

By doing this the ship starts pitching up on load by itself, which is good (Ill bind the rotation to a key later on) but the problem is that whenever I press any "WASD" key to move the ship resets it's position back to flat and continues moving forward relative to the groud,or x and z axes. (And it wont pitch up anymore eventhough I have the Rotation line on the Update() function.)

Im thinking that by default, the 3rd peson controller uses the world axes to move forward and backwards and it is not moving relative to the ship's axes. Am i right here?

So, is there any way I can make the "W" key move the ship to where it is looking, instead of relative to the scene x and z axes?

Thanks everyone!

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 Glurth · Jan 09, 2015 at 09:46 AM 0
Share

The fact that it is resetting the orientation of the ship, every time a WSAD key is pressed makes me suspect the problem lies with the 3rd person controller, that actually responds to these keypresses. Perhaps it does not use transform.Rotate(some amount) like you do, but rather tranform.rotation= some value; This would overwrite any rotation you may have applied previously. You mentioned binding the rotation to a key: I'd suggest you go "all-in", and do the same for the other two axis, making your own controller to ensure consistency.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by livevlad · Jan 09, 2015 at 09:48 AM

To move your ship / plane to where it is looking, do something like :

 this.transform.position += this.transform.forward * speed * Time.deltaTime;
 // "this" is your ship
 // "speed" is a float for .... the ship's speed
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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to lock X rotation; broken script 0 Answers

Help regarding World-Local Transfrom Rotation? 1 Answer

Move an object toward an angle in 2d space 0 Answers

how to get the absolute direction? 1 Answer

How to lock a transform's local up axis rotation on any surface 1 Answer


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