- Home /
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
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).
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.
Your answer
Follow this Question
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