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 unity_7CKdbuD6TRclOQ · Dec 16, 2019 at 06:04 PM · camerascripting problemversionnew user

Why are my scripts not working after I opened project in newer version?,Project Scripts broken after opening project in newer version

I opened my project in 2019.2.15 instead of 2018.4.13, not my scripts arent working properly.

-my player isnt moving in the camera's direction . -My camera won't pivot in the vertical around my player.

Please help!

Code:

public class CameraMovement : MonoBehaviour {

 public float rotateSpeed;
 public Transform player;
 public Vector3 offset;
 public Transform PivotPoint;
 public float maxCamAngle;
 public float minCamAngle;
 public int invertYaxis; // set this to any negative or positive value *****************************************

 // Start is called before the first frame update
 void Start()
 {
     offset = player.position - transform.position;
     PivotPoint.transform.position = player.transform.position;
     PivotPoint.transform.parent = player.transform;
     Cursor.lockState = CursorLockMode.Locked;
 }

 // Update is called once per frame
 void LateUpdate()
 {
     //Sets the angle of the camera according to the rotation of the player in X axis
     float rightXAngle = PivotPoint.eulerAngles.x;
     float horizontal = Input.GetAxis("Mouse X") * rotateSpeed;
     player.Rotate(0, horizontal, 0);

     //Sets the angle of the camera according to the rotation of the player in Y axis
     float rightYAngle = player.eulerAngles.y;
     float vertical = Input.GetAxis("Mouse Y") * rotateSpeed;
     PivotPoint.Rotate(vertical, 0, 0);

     //Sets Camera LOCATION according to pivot of the player
     Quaternion rotation = Quaternion.Euler(rightXAngle, rightYAngle, 0);
     transform.position = player.position - (rotation * offset);

     //Makes it so that camera doesnt clip through the ground and gets closer
     if(transform.position.y < player.position.y) {
       transform.position = new Vector3(transform.position.x, player.position.y -0.01f, transform.position.z);
     }

     //stop camera from turning 360 degrees in axis
     if( PivotPoint.rotation.eulerAngles.x > maxCamAngle && PivotPoint.rotation.eulerAngles.x <100f) {
       PivotPoint.rotation = Quaternion.Euler(maxCamAngle ,0,0);
     }

     if(PivotPoint.rotation.eulerAngles.x > 180 && PivotPoint.rotation.eulerAngles.x < 360f - minCamAngle) {
       PivotPoint.rotation = Quaternion.Euler(360f - minCamAngle,0 ,0);
     }

     //centers Camera
     transform.LookAt(player);
 }

}

and

public class PlayerMovement : MonoBehaviour {

 public float moveSpeed;
 public Rigidbody RB;
 public float jumpForce;
 public CharacterController controller;
 private Vector3 moveDirection;
 public float gravityScale;
 public float windUpTimeLow;
 public float windUpTimeMedium;
 public float windUpTimeHigh;
 float startTimer;
 public Material green;
 public Material orange;
 public Material red;

 void Start() {
   controller = GetComponent<CharacterController>();
   Debug.Log("Game Has Started");
 }

 // Update is called once per frame
 void Update() {
   float yStore = moveDirection.y;

   moveDirection = (transform.forward * Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime) + (transform.right * Input.GetAxis("Horizontal") * moveSpeed * Time.deltaTime);
   moveDirection.y = yStore;

   moveDirection.y = moveDirection.y + (Physics.gravity.y * gravityScale * Time.deltaTime);
   controller.Move(moveDirection * Time.deltaTime);

   if(moveDirection.y > 0f) {
     startTimer = 0f;
     GetComponent<Renderer>().material = green;
   }

   //makes the player wind up his jump according to the time he held space
   if(controller.isGrounded) {
     if(Input.GetButtonDown("Jump")) {
       startTimer= Time.time;
     }
     if(Input.GetButtonUp("Jump") && Time.time - startTimer <= windUpTimeLow) {
       Debug.Log(startTimer);
       moveDirection.y = 1.5f * jumpForce;
     }
     if(Input.GetButtonUp("Jump") && windUpTimeLow < Time.time - startTimer && Time.time - startTimer  <= windUpTimeMedium) {
       Debug.Log(startTimer);
       moveDirection.y = 2f * jumpForce;
     }
     if(Input.GetButtonUp("Jump") && Time.time - startTimer >= windUpTimeHigh) {
       Debug.Log(startTimer);
       moveDirection.y = 2.5f * jumpForce;
     }
     if(windUpTimeLow < Time.time - startTimer && Time.time - startTimer  <= windUpTimeMedium && startTimer > 0f) {
       GetComponent<Renderer>().material = orange;
     }
     if(windUpTimeMedium < Time.time - startTimer && Time.time - startTimer <= windUpTimeHigh && startTimer > 0f) {
       GetComponent<Renderer>().material = red;
     }
   }

} }

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 hexagonius · Dec 16, 2019 at 08:39 PM 0
Share

$$anonymous$$y first guess is, the console tells you. $$anonymous$$y second is, the Input $$anonymous$$anager either changed or what you're using as axis and button strings is not setup in the manager anymore.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by sherry_f · Dec 16, 2019 at 11:55 PM

It would help if you look for deprecated API in the documentation. Maybe either of these link could be a good starting point : https://unity3d.com/unity/whats-new/2019.2.15 https://docs.unity3d.com/ScriptReference/Transform.html

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

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

Problem with a Unity Scripting example from the scripting manual! 0 Answers

What's the basis behind camera system? 0 Answers

script does not work when you open the Unity 1 Answer

View Matrix Camera rotation problem 0 Answers

Placing a dynamic board in the exact Center of the Camera 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