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 tayyab43 · Nov 29, 2014 at 02:30 PM · uicamera-movementlerpslerp

Slerp Probems

Im doing the Menu screen for my game and i'm currently using unity's new UI system. When the Options button is pressed then I need the camera to move and rotate slowly to a place.This seems really easy but for some reason it doesn't slerp no matter what i put in and it lerps to a completely random place? here's my code:

 using UnityEngine;
 using System.Collections;
 
 public class MainMenuCaller : MonoBehaviour {
     
     public GameObject MainCam;
     public Vector3 movePos=new Vector3(-6.1232f,-0.30558f,20.013f);
     public GameObject canvas;
     public bool Moved=false;
     public GameObject NewCanvas;
     public bool Instantiated=false;
     public Quaternion OptionsCamRot= new Quaternion(0,67.69f,0,0);
     public Vector3 CameraMovePos= new Vector3(-3.4777f,-0.30558f,22.199f);
 
     public void Exit()
     {
         Application.Quit ();
     }
 
     public void CampaignStart()
     {
         Application.LoadLevel ("campaign");
 
     }
     public void Online()
     {
 
         MoveCam ();
 
     }
     public void MoveCam()
     {
         MainCam.transform.position = Vector3.Lerp (MainCam.transform.position, movePos, 1.5f * Time.deltaTime);
         Destroy(canvas,4f);
         Invoke ("OnlineMenu", 4f);
 
     }
 
     public void OnlineMenu()
     {
     
         Instantiate (NewCanvas);
         CancelInvoke();
 
 
     
     }
 
     public void Options()
     {
         MainCam.transform.position = Vector3.Lerp (MainCam.transform.position, CameraMovePos, 1.5f * Time.deltaTime);
         MainCam.transform.rotation = Quaternion.Slerp (MainCam.transform.rotation, OptionsCamRot, 1.5f * Time.deltaTime);
     }
 
 
 }

 
Comment
Add comment · Show 5
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 tayyab43 · Nov 29, 2014 at 05:54 PM 0
Share

I can't seem to find an answer anywhere

avatar image Swaggre · Nov 29, 2014 at 06:05 PM 0
Share

You need to call $$anonymous$$oveCam() continuously maybe move the lerp to some Update() function. If it lerps to a random place you might be using local coordinates, so try switching transform.position to transform.localPosition

avatar image tayyab43 · Nov 30, 2014 at 02:47 PM 0
Share

$$anonymous$$ove cam is being done continuosley and the camera isn't a child of anything?

avatar image tayyab43 · Nov 30, 2014 at 03:15 PM 0
Share

Ive tried everything it still doesn't work

avatar image tayyab43 · Nov 30, 2014 at 03:25 PM 0
Share

If anyone has a solution please, it would be highly appreciated

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by b1gry4n · Nov 30, 2014 at 03:26 PM

I suggest you follow this guide on using lerp:

http://www.blueraja.com/blog/404/how-to-use-unity-3ds-linear-interpolation-vector3-lerp-correctly

Comment
Add comment · Show 8 · 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 tayyab43 · Nov 30, 2014 at 03:29 PM 0
Share

thats basically exactly what i did????

avatar image b1gry4n · Nov 30, 2014 at 03:29 PM 0
Share

no it isnt, youre using time.deltatime. read the guide, trust me

avatar image b1gry4n · Nov 30, 2014 at 03:33 PM 0
Share

using a lerp with time.deltatime may work, but it is incorrect. The guide will explain this. The reason your code isnt working is because you are not continuously updating your lerp. I dont even see an Update() in your code. Luckily though, you will not be using Update() if you follow the guide and understand it

avatar image tayyab43 · Nov 30, 2014 at 03:37 PM 0
Share

no because im updating as an event trigger in the inspector using unity's UI system

avatar image tayyab43 · Nov 30, 2014 at 03:37 PM 0
Share

BTW it isn't slerping at all either

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Lerp Rotation C# 3 Answers

Keeping UI Element To Game Object When Camera Moves 2 Answers

Crouching script not working? 0 Answers

Is it good idea to implement camera drag with UI drag event? 2 Answers

Moving the player toward a direction 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