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 /
avatar image
0
Question by Carlose64 · Feb 19, 2019 at 02:59 AM · scripting problemcamera rotate

smooth camera rotation problem

So... I've been trying to make a simple 3rd person script where the camera follows the player. I figured that the camera rotation of the player should be smooth. This is where I've been having trouble. I've tried to refit script from the camera following the translation of the player but it doesn't seem to work. Hopefully this is an easy fix. alt text Sorry about this, I've just started to learn with unity's scripting tutorials... It hasn't done me much good in this situation.

pooblems2.png (45.4 kB)
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 Captain_Pineapple · Feb 19, 2019 at 08:55 AM 1
Share

If you simply pasted your code in your post it would simplify it for others to edit it and add possible answers.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by xxmariofer · Feb 19, 2019 at 09:06 AM

dont access the transform of a transform. dont do Target.transform change it to Target.rotation/position. second you need to lerp the roation not the position so you need to access the Target.rotation and calculate the desired rotation. also in the last line you are probably missing a '+'. not sure if you are missing something else.

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 Carlose64 · Feb 20, 2019 at 12:51 AM 0
Share

unfortunately, there is now a problem on 'DesiredPosition'. The error states that it's not able to convert a Vector3 to a Quaternion

 public Transform Target;
 public Vector3 offset;
 float Smooth = 0.25f;
 // Use this for initialization
 void Start () {

 }
 
 // Update is called once per frame
 void Update () {
     Vector3 desiredPosition = Target.transform.position + offset;
     transform.rotation = transform.rotation.Lerp(***desiredPosition***, Target.rotation, Smooth);
     transform.LookAt(Target);
     transform.position = Target.position + offset;
avatar image xxmariofer Carlose64 · Feb 20, 2019 at 10:38 AM 0
Share

you are mixing position and rotation, and the code makes no sense, you want the object to lerp the position or the rotation? but if you only want to get that code going you can change that line to this

         transform.rotation = transform.rotation.Lerp(Quaternion.Euler(desiredPosition), Target.rotation, Smooth);
avatar image Carlose64 xxmariofer · Feb 20, 2019 at 10:55 PM 0
Share

I apologize, but the script haws another flaw. This is one I can't figure out, like the last 2. The problem is now the transform.rotation.Lerp has an error. It states that it can't be accessed with an instance reference. It proceeds to suggest to qualify with a type name ins$$anonymous$$d. Here's the code:

 public Transform Target;
 public Vector3 offset;
 float Smooth = 0.25f;
 // Use this for initialization
 void Start () {

 }
 
 // Update is called once per frame
 void Update () {
     Vector3 desiredPosition = Target.transform.position + offset;
     transform.rotation = transform.rotation.Lerp(Quaternion.Euler(desiredPosition), Target.rotation, Smooth);
     transform.LookAt(Target);
     transform.position = Target.position + offset;
 }

}

unimportant: I apologize if I'm a nuisance to anyone, this 'code' has an extent before in my $$anonymous$$d it becomes gibberish

Show more comments

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

177 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Problems with Gyroscope VR Car Game 0 Answers

Clamp a Vector above minimum angle from another Vector? 0 Answers

What is wrong in my camera rotator script ? 0 Answers

View Matrix Camera rotation problem 0 Answers

How to make that the camera will not go through the walls? 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