Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
This question was closed Aug 21, 2018 at 05:34 PM by PeacefulWhale for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by PeacefulWhale · Jul 23, 2018 at 02:54 PM · transformtransform.forward

transform.forward with rotation offset variable?

(dang, none of my writing saved when I had to sign in...) My character is in a basic 3rd person setup So I have an issue in my code. I am using transform.forward to move my character depending on their rotation. However when it moves forward/back and right/left, I have it turn 45 degrees. I like the way this looks better than a different animation.

The problem is when I do this, the transform.forward is also effected by the rotation offset... Because it is already moving at a 45 degree angle (I am adding transform.right and transform.forward to move) it just ends up just moving to the right...
I don't know how to really solve this... I was thinking of moving the camera, but I want the camera to dictate the movement of the character, not the other way around.

If this doesn't make sense, I am trying to move the way fortnite moves (at least how the run forward/right), but I can't get the transform.forward to ignore the offset rotation... Is there anyway to change this?

Can I make it so I can have an offset to the transform.forward? Would it be better to find a different function to do this? If so, which one? Should I just give up?

This is how I set the target rotation. NewRot = Quaternion.Euler(NewX, (NewY + strafeOffset), NewZ); transform.rotation = Quaternion.Lerp(OldRot, NewRot, (Time.deltaTime * rotation));

//NewY is the rotation of the camera, that way it rotates with the camera...
//rotation is the rotation speed.,In my script, the character moves forward based off its rotation using transform.foward.

They are controlled by the camera rotation, so transform.forward was the easiest way for them to move forward based off it's rotation.

However when they move diagonally, I rotate the character by 45/-45 degrees. This way it looks like they're running in that direction but still follow the camera. Like Fortnite actually. Sadly, the transform.forward is effected by this rotation, and they end up not moving the way they're supposed to because of the 45 degree rotation added onto the 45 degree movement I get from the transform.forward and transform.right.

Is there anyway to add an offset to the transform.right? Is it possible to make it so it ignores my rotation offset variable through addition or something? What would be the best way of getting over this issue?

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

  • Sort: 
avatar image
0
Best Answer

Answer by PeacefulWhale · Aug 21, 2018 at 05:34 PM

So, I'm just going to mark this as answered...

Here are some ways I think will work, they don't really answer the my core question, but they are suitable work arounds.

You can work around it by just animating the character at that rotation.

You can also make an empty object, and parent the character to this, and make the character controller in the empty game object. This way you can rotate the character without rotating the character controller.

I believe rotating the mesh object will have the same effect.

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

Follow this Question

Answers Answers and Comments

171 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do you maintain gravity using transform.forward and transform.right? 0 Answers

Lerp Random Position - Within Original Vector3 1 Answer

How can I work with the opposite angle? 0 Answers

transform.lookat not working? 0 Answers

how can my move a obect alon with the player 2 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