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 pebblechan · Nov 14, 2019 at 07:04 AM · movementterrainmovement scriptworkingstopped

Movement worked yesterday but doesn't anymore? I did not make any changes in script

Just as the question says - yesterday, my game worked smoothly. The player was moving nicely. Here is a gif showing how it used to move! alt text

Here is my simple movement script:

 public class Movement : MonoBehaviour {
    
    
     public float playerSpeed = 5.0f;
     public float smooth = 5.0f;
     public float tiltAngle = 90; 
     public float speed;
 
     
     void Start ()
     {
         //player spawns here
        
         transform.position = new Vector3(385, 0, 318);
 
     }
     
    
     // Update is called once per frame
     void Update (){
     Physics.gravity = new Vector3(0, -120f, 0);
     
 
 if(Input.GetKey(KeyCode.W)){
      transform.Translate(0,0,5*Time.deltaTime);
      // Rotate the cube by converting the angles into a quaternion.
         transform.rotation = Quaternion.Euler(0, -90, 0);
     
  }if(Input.GetKey(KeyCode.S)){
      transform.Translate(new Vector3(0,0,5)*Time.deltaTime);
      transform.rotation = Quaternion.Euler(0, 90, 0);
      
  }if(Input.GetKey(KeyCode.D)){
      transform.Translate(0,0,5*Time.deltaTime);
      // Rotate the cube by converting the angles into a quaternion.
         transform.rotation = Quaternion.Euler(0, 0, 0);
  
  }if(Input.GetKey(KeyCode.A)){
      transform.Translate(new Vector3(0,0,5)*Time.deltaTime);
      // Rotate the cube by converting the angles into a quaternion.
         transform.rotation = Quaternion.Euler(0, 180, 0);
      
  }
  
      
  
  }
  
     }

I did not change anything in the script since yesterday. However, for some reason, the chicken doesn't move anymore today. See the gif with today's chicken:

alt text

I have no idea why this is happening today. But, clearly, my animation script still works, my jump script works, my camera rotation & zoom in/out script works too.

I will add my chicken's Inspector bar in an answer below.

I find it so strange that what was once working yesterday, doesn't anymore! Any response what be greatly appreciated. Thanks.

ezgifcom-gif-maker.gif (488.0 kB)
ezgifcom-optimize.gif (506.2 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 pebblechan · Nov 18, 2019 at 11:04 AM 0
Share

UPDATE - I found that when I disable my Jump script, the chicken walks again, with or without Character controller! So, I think my Jump script it causing my $$anonymous$$ovement script to not work?

But I have no idea why...

Here is my Jump script:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class Jump : $$anonymous$$onoBehaviour
 {
     public Animator anim;
     private CharacterController controller;
     private float verticalVelocity;
     private float gravity = 14f;
     private float jumpForce = 5.0f;
 
 
     // Start is called before the first frame update
     void Start()
     {
         controller = GetComponent<CharacterController>();
         anim = GetComponent<Animator>();
 
     }
 
     // Update is called once per frame
     void Update()
     {
         if (Input. Get$$anonymous$$eyDown($$anonymous$$eyCode.Space))
         {
             anim.Play("Run In Place");
         }
         
         if (Input. Get$$anonymous$$eyUp($$anonymous$$eyCode.Space))
         {
             anim.Play("Idle");
         }
         
         if(controller.isGrounded){
      verticalVelocity = -gravity * Time.deltaTime;
      if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Space))
      {
          verticalVelocity = jumpForce;
      }
  } else {
      verticalVelocity -= gravity * Time.deltaTime;
  } Vector3 moveVector = new Vector3 (0,verticalVelocity,0);
  controller.$$anonymous$$ove(moveVector * Time.deltaTime);
     }
 }
 


Please I'd really appreciate some help with this! Its been driving me nuts!

Thank you.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by pebblechan · Nov 14, 2019 at 07:06 AM

Screenshot of chicken's Inspector panel.

I found when I toggle off "Character Controller", the chicken moves again but not as smoothly as it used to yesterday. Character Controller was on yesterday though so I'm not sure if that is the issue?!

alt text


screen-shot-2019-11-14-at-100208-am.png (187.4 kB)
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
avatar image
0

Answer by goutham12 · Nov 14, 2019 at 09:08 AM

why you are change gravity that to in update. and also you are using character controller.

refer this links copy the whole script and give a try

https://docs.unity3d.com/ScriptReference/CharacterController.Move.html

https://docs.unity3d.com/ScriptReference/CharacterController.SimpleMove.html

Comment
Add comment · Show 1 · 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 pebblechan · Nov 14, 2019 at 10:57 AM 0
Share

Hey thanks for your reply! I am also not sure why

Physics.gravity = new Vector3(0, -120f, 0);

is in update. I'm still new to Unity and tried to keep my script as simple as possible so that I understand all the elements.

This line may have been something I added for a different purpose. In any case, I removed that line and yet still have the same problem -- the chicken doesn't move! :( So, that line is not the issue.

Thanks for the links but I'd prefer to get to the root of this problem and not try other scripts because like I said, this script was working perfectly yesterday...

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

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

Related Questions

Can't move camera parent from child script with camera on timeline movement 0 Answers

Moving forward seems to be specific to the original direction of the object being controlled 0 Answers

My 2d movement script isn't working 0 Answers

Unusual movement script. Any ideas how to do that? 0 Answers

Limit movement to just forward/backward and left/right 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