Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 gospel_gamer · Aug 15, 2015 at 05:10 PM · c#rigidbodygravitycubecapsule

Issue w/ Difference between Cube and Capsule

So this may be an easy answer but I'm having a hard time figuring out the cause of the problem. Since I am a beginner I've decided creating a "Movement playground" scene would be a good start - it would allow me to learn the basics of the Unity interface and allow me to learn what the classes that Unity offers are (plus basic C# syntax). I've setup a small scene with a Cube set as a player (with a rigidbody attached that uses Gravity) and attached the script copied below. As a side note: I added the rigidbody specifically so I could take advantage of the gravity feature for giving the player the ability to jump and not worry about how to return the player to the ground; however, now when I move (after adding gravity to the mix) the player jitters and shutters across the plane I've set as the ground as opposed to smoothly gliding across it. I've tested to see if this is the case with anything else by creating another Player in the scene but using a Capsule - same setup with the rigidbody. The capsule glides across just fine but the cube seems to drag/shutter. Is there a reason someone knows that would cause this?

 using UnityEngine;
 using System.Collections;
 
 public class PlayerMoveGetAxis : MonoBehaviour {
     void Start()
     {
         Debug.Log("Initialized");
     }
     // Update is called once per frame
     public float speed = 1.0f;
     public float jumpspeed = 3.0f;
     void Update () 
     {
         float moveForward = Input.GetAxis("Vertical");
         float turning = Input.GetAxis("Horizontal");
         {
             //General Movement
             if (moveForward != 0)
             {
                 transform.Translate(Vector3.forward * moveForward * speed * Time.deltaTime);
             }
             if (turning != 0)
             {
                 transform.Rotate(0, turning, 0);
             }
             //Sprinting
             if (Input.GetKeyDown(KeyCode.LeftShift))
             {
                 Debug.Log("Left Shift pressed down.");
                 speed = 5.0f;
             }
             if (Input.GetKeyUp(KeyCode.LeftShift))
             {
                 Debug.Log("Left Shift released.");
                 speed = 1.0f;
             }
             //Jump
             if (Input.GetButton("Jump"))
             {
                 transform.Translate(Vector3.up * jumpspeed * Time.deltaTime);
             }
         }
     }
 }

*Code addedfor any verification purposes that might be necessary for troubleshooting

Comment
Add comment · Show 2
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 gospel_gamer · Aug 15, 2015 at 05:52 PM 0
Share

Should I use AddForce ins$$anonymous$$d? I am currently using that to jump (it's a bit glitchy so there's some kinks I need to work out with it).

avatar image cjdev · Aug 15, 2015 at 08:43 PM 0
Share

I tested it and didn't notice any stuttering but you could try putting the Update logic in FixedUpdate ins$$anonymous$$d and see if that helps.

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Make A Cube 'Sticky' 4 Answers

Making a cube fall without rigidbody 1 Answer

Object shattering under a certain weight/force 3 Answers

Multiple Cars not working 1 Answer

Gravity is not working if i use rigidbody.velocity 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