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 NovaDrox · Jul 09, 2017 at 05:22 AM · camerapositionvector3transform.positionvector3.lerp

Child GameObject is aligned to world axis and not the parents axis (UPDATE)

This is driving in me insane, and it worked before, but not now. I have my player camera set up as a child of the player. Then I have some small key pressing statements to change the position of the camera, but when I press one of them, it sets the camera to the world axis and not the player. The second thing I need to figure out is how to lerp each position, so when you press a new position, it smoothly goes to that position instead of jumping it.

UPDATED:

So, I figured out my lerping problem, but I am still stuck with my child object not moving around the player's axis. It's still stuck to the world's axis.

Here's my script: [Header("Camera Info")]

 [SerializeField]
 private GameObject PlayerCamera;
 [SerializeField]
 private Transform PlayerCamPosition;
 [SerializeField]
 private Transform FocalPoint;

 public float Smoother;

 [Space]
 public Vector3[] CameraPositions;
 private Vector3 Current;

 private void Start()
 {
     if (Camera.main != null)
     {
         Camera.main.transform.gameObject.SetActive(false);
     }

     Current = CameraPositions[0];
 }

 private void Update()
 {
     SetPosition();
     ChangeCamPosition(Current);
 }

 private void SetPosition()
 {
     PlayerCamera.transform.LookAt(FocalPoint);

     if (Input.GetKeyDown(KeyCode.Alpha1))
     {
         Current = CameraPositions[1];
     }

     if (Input.GetKeyDown(KeyCode.Alpha2))
     {
         Current = CameraPositions[0];
     }

     if (Input.GetKeyDown(KeyCode.Alpha3))
     {
         Current = CameraPositions[2];
     }
 }

 private void ChangeCamPosition(Vector3 Position)
 {
     PlayerCamera.transform.position = Vector3.Lerp(PlayerCamPosition.position, Position, Smoother);
 }
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
0

Answer by kaway · Jul 09, 2017 at 06:02 AM

Instead of changing the position of the cameras better Create 3 chambers And place them where you want them to go each and there Comes with a new and simpler script

 public class Camera: MonoBehaviour {
 
 public GameObject[] Camera;
 
 Void Start() {
 }
 
 Void Update () {
 if (Input.GetkeyDown(KeyCode.Alpha1)){
 Camera[0].SetActive(true);
 Camera[1].SetActive(false);
 Camera[2].SetActive(false);
 }
 if (Input.GetkeyDown(KeyCode.Alpha2)){
 Camera[0].SetActive(false);
 Camera[1].SetActive(true);
 Camera[2].SetActive(false);
 }
 if (Input.GetkeyDown(KeyCode.Alpha3)){
 Camera[0].SetActive(false);
 Camera[1].SetActive(false);
 Camera[2].SetActive(true);
 }
 }
 }
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 NovaDrox · Jul 09, 2017 at 06:09 AM 0
Share

That would work, if I wasn't trying to do the lerp thing.

avatar image Jwizard93 NovaDrox · Jul 09, 2017 at 11:39 PM 0
Share

The camera is a child? perhaps you want to update it's localPosition ins$$anonymous$$d of its position.

avatar image NovaDrox Jwizard93 · Jul 10, 2017 at 02:16 AM 0
Share

I tired that and it still on the world axis.

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

110 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

Related Questions

Trouble converting transform.position to C# 1 Answer

How to detect VR camera movement? 0 Answers

Make the character follow the images one by one smoothly 1 Answer

Moving the Camera Up and Down by pressing Key 2 Answers

How to keep the same position of the object instead of camera 0 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