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 soranthalas · Feb 08, 2015 at 02:15 AM · transform.forward

Can you change an object's forward without rotating it?

I'm working on a very simple 2D game on the XZ plane. I've created a simple cylinder which I'm using as a missile. I rotated the object so the length of the cylinder is pointed in the right direction, but the Y axis is now pointing down, so when I use transform.foward() it falls down through the background instead. I could use transform.up() and the object moves in the right direction. But when I later want to fire the missile toward a mouse-click, I can't just use transform.Lookat(), I'll have to adjust it.

Is there a way to redefine what my "forward" direction is without rotating the object?

Thanks in advance.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by VesuvianPrime · Feb 08, 2015 at 02:18 AM

Changing the forward of a transform without rotating it does not make any sense. A better approach may be to parent your cylinder to another object. This way you can rotate the cylinder and use the parent for orientation.

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 soranthalas · Feb 08, 2015 at 03:28 AM 0
Share

Imagine you had a car that you were moving with transform.forward(). Now imagine that ins$$anonymous$$d of traveling in the direction of the hood, it moved laterally toward the driver side. That's my issue. I could rotate the car so that it moves in the correct direction, but it still wouldn't be moving in the direction of the hood. No matter how I rotate the object, the "forward" direction is sideways out of the driver side. I need to redefine what "forward" is on this object, which is just a cylinder in my 2D game.

avatar image Rohit-M · Feb 08, 2015 at 03:32 AM 0
Share

What VesuvianPrime said should fix your problem. If you use an empty game object as a parent, parent the car to it, rotate the car and then use transform.forward() on the empty game object, it should move your car in the desired direction.

avatar image tanoshimi · Feb 08, 2015 at 09:24 AM 0
Share

An even better way would be to edit your model in a 3d modelling program to ensure that it's "forward" direction was facing down the positive z axis.

avatar image soranthalas · Feb 08, 2015 at 03:12 PM 0
Share

Ves and Rohit: Somehow that made sense the second time I read it. The missile already has an empty parent object acting as its spawn point, and I don't want that to move. But I can include another for this job.

Tano: There's no model. This is a basic 3D cylinder in Unity.

avatar image
0

Answer by richardgengle · Aug 02, 2020 at 05:24 AM

sprites can be flipped without rotating in inspector

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

Fire bullet in camera direction problem 3 Answers

Is there any way to translate normalized vectors into angles? 1 Answer

Rotate object around transform.forward 1 Answer

setting Transform.forward results in strange artifact 2 Answers

Eulerangles and Transform.forward... something's off? 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