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 ryft82 · Oct 01, 2014 at 09:15 PM · rotationmovementy-axis

Adjust Y smoothly regardless of object rotation

So, first off I apologize if I do this wrong, this is my first time here.

I'm in the process of self-teaching Unity/C# and starting to get a feel for more involved object movement, and I'm trying to figure out a decent way to change the Y value by a set amount smoothly by pushing + or - without regard to GameObject orientation.

Now, I've read various things, and looked at tons of projects that had some form of similar setup but I seem to just be having an issue getting anything to work the way I want it to, so I was hoping that maybe someone could break it down for me in some way that it makes sense or point me in the right direction.

Basically I have my camera that rotates around an Empty as a "center" that has capability of zooming and free orbit around that center point, and I'm trying to build in the Pan/Trolley controls, but my Up/Down movement is always in relation to the Camera Local Up (still haven't figured out Z movement either, but once I can handle the Up/Down movement, I should be able to tweak it to fit).

Anyway, any sort of help would be appreciated. Though I'm not necessarily asking for anyone to write up the code for me, more just guide an inexperienced but hungry student, so if anything beyond pointing me in the right direction I would prefer pseudo-code at best so I can figure it out on my own. Again, thanks for any help or direction.

Comment
Add comment
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

1 Reply

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

Answer by tanoshimi · Oct 01, 2014 at 09:19 PM

Move up in world space:

 transform.position += Vector3.up * Time.deltaTime;

Move up in local space:

 transform.position += transform.up * Time.deltaTime;
Comment
Add comment · Show 3 · 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 ryft82 · Oct 01, 2014 at 09:37 PM 0
Share

That seems to work just fine, any tips how to get an equivalent "relative" forward motion? I know Vector3.forward will move according to world, but I'd like to move on that same plane of movement, just with the "forward" direction being relative to my Y rotation rather than World.

avatar image tanoshimi · Oct 01, 2014 at 09:53 PM 0
Share

That would be transform.forward ins$$anonymous$$d of Vector3.forward :)

avatar image ryft82 · Oct 01, 2014 at 10:14 PM 0
Share

Well, Vector3.forward is world forward space. transform.forward is object forward space, but what I want is an "artificial forward" that operates like Vector3.forward, but that uses the Y rotation, to define what that "forward direction" is. Basically my camera should be able to face any direction, and have the forward motion only take place on the x/z axes of movement...sort of a hybrid between Vector3.forward and transform.forward. Sorry if that doesn't make sense.

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

2 People are following this question.

avatar image avatar image

Related Questions

How To Make a 3d object follow mouse and move towards it while the camera is following that 3d object? 1 Answer

Rotating Character 1 Answer

Rotate an object such that it is theta degrees relative to another object 1 Answer

Top down space game Rotation help. 0 Answers

Making RigidBody face direction for movement 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