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 /
avatar image
0
Question by shpetim_91 · Mar 08, 2016 at 05:10 PM · movementcamera rotatecamera-lookcamera follow

How to make my camera follow the ball smoothly, because when the players touch the camera is not really stable

using UnityEngine; using System.Collections;

public class Camera_Script : MonoBehaviour {

 private bool isTriggering = false;
 private float distanceAdder = 0.0f;
 private float distanceAdder2 = 0.0f;
 private bool isExit = false;
 public Transform target;
 
 public Vector3 targetOffsetPos;
 private Vector3 oldPos;    
 
 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void LateUpdate () {
 
     
     if ( GetComponent<InGameState_Script>().state == InGameState_Script.InGameState.PLAYING 
         || GetComponent<InGameState_Script>().state == InGameState_Script.InGameState.Run
         || GetComponent<InGameState_Script>().state == InGameState_Script.InGameState.Remove) {
         oldPos = transform.position;
         Vector3 newPos = new Vector3( target.position.x+targetOffsetPos.x, target.position.y+targetOffsetPos.y, target.position.z+targetOffsetPos.z );
         
         float lerpX =  Mathf.Lerp( oldPos.x, newPos.x,  0.05f );
         float lerpY =  Mathf.Lerp( oldPos.y, newPos.y,  0.05f );
         float lerpZ =  Mathf.Lerp( oldPos.z, newPos.z,  0.05f );
         
         transform.position = new Vector3( lerpX, lerpY, lerpZ );            transform.LookAt( target );
     }
     
     if ( GetComponent<InGameState_Script>().state == InGameState_Script.InGameState.CORNER_1
         || GetComponent<InGameState_Script>().state == InGameState_Script.InGameState.CORNER) {
     
     
         GameObject lanzador = GetComponent<InGameState_Script>().candidateToKick;
     
         if ( lanzador ) {
         
             transform.position = lanzador.transform.position - lanzador.transform.forward*15.0f + lanzador.transform.up*3.0f ;
             transform.LookAt( target );
         
         }
         
     
     }        
     
 }

}

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 Le-Pampelmuse · Mar 09, 2016 at 07:05 AM 1
Share

Hi.

This is not a scripting service. Posting your whole script without explaining anything in detail in the question body is not appropriate on UA. Your Question title should be short and descriptive.

when the players touch the camera is not really stable

..what is this supposed to mean?

How to make my camera follow the ball smoothly

..there are many many tutorials for this. Check Google, Forums or Youtube for tutorials. Not UA. Check the FAQ to the top right of the page for information about how to use UA.

Have a nice day, everyone starts as a beginner somewhere. ;)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Orthrinicus · Mar 08, 2016 at 09:54 PM

@shpetim_91 this link may help with what you are trying to do, it basically just shows you a script that smoothly follows an object in the scene:

https://unity3d.com/learn/tutorials/projects/survival-shooter/camera-setup?playlist=17144

it starts at around 2:00 till the end

enjoy

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

6 People are following this question.

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

Related Questions

I want to make rotation on XZ axis. But it rotates at XYZ every axis. Can anybody tell me how can I do XZ rotation? 0 Answers

Top-Down Camera view (with rotation) need help (third person script) 0 Answers

getting Jittery movement on camera when player rotating and moving in same time 0 Answers

CineMachine Camera Movement is inverse 1 Answer

Camera rotation on mouse input 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