Noob with Collision Question - Jittery

Hi,

I have a simple question but I’m having a hard time understanding what the solution is.
I create very simple player and platform game objects. When the two collide and I move the player, there is a jitter/bounce that happens as the player gets sucked into the platform and gets shot out the other side.
Both objects have box colliders. The player has a Rigidbody (with gravity turned on).

Here is how I’ve created the game.
Platform
I Create a New 3D Object => New => Cube
Change the scale so that it looks like a platform

Player
I Create a New 3D Object => New => Cube
Add a Rigidbody (leaving all settings to default)
Create a Script:
float targetSpeed = Input.GetAxisRaw (“Horizontal”) * speed; // speed is a public float variable
rb.AddForce (targetSpeed, 0.0f, rb.velocity.y); // rb is the Rigidbody initialized in the Start function

I have no idea what can cause the collisions between the two objects to gradually get sucked into one another?

Any help is greatly appreciated!

I have tested your script, See here;

using UnityEngine;
using System.Collections;

public class SFDCIVimyProject : MonoBehaviour {

    public float speed;
    private Rigidbody rb;
    // Use this for initialization
    void Start () {
        rb = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update () {
        float TargetSpeed = Input.GetAxisRaw("Horizontal") * speed;
        rb.AddForce (TargetSpeed, 0.0f, rb.velocity.y);
    }
}

With this code, The Player (Cube) was rotating. Here is the fix

Step 1 : Add a ground

    • You can use scaled cube or a plane
  • Do not change any other

Step 2 : Add the player

    • Add new cube
  • Set position Above the ground

Step 3 : Character Controller

    • Add a Character Controller to the player object
  • Use Add Component > Physics > Character Controller

Step 4 : Add Controller Script

    • Add New Script

using UnityEngine;
using System.Collections;

public class SFDCIVimyProject : MonoBehaviour {

public float speed; // From your script
private CharacterController charactor; // Changed for fixing

// Use this for initialization
void Start () {

    charactor = GetComponent<CharacterController>(); // Changed for fixing
}

// Update is called once per frame

void Update () {

    float targetSpeed = Input.GetAxisRaw ("Horizontal") * speed; // From your script
    charactor.SimpleMove(Vector3.right * targetSpeed); // Changed for fixing
}

}

- *Step 5 : Endings**

- Set the speed to 5 - 10 in *Inspector*
- Be sure your are not changed the _**input**_ settings
- Use the _* Time.deltaTime_ if you need smoother movement
- if you using Time.deltaTime, Increase the value of speed

I think i have fixed your problem

Thanks, I appreciate your help and that did work.

Why would the rotation of the original player (Cube) cause this odd behaviour in the first place?

Does adding the Character Controller fix this issue because it’s adding some sort of ‘skin’ in between the objects that are colliding?

Thanks again

sorry if i am too late.

A cube cannot move freely with it’s sharp edges. Rigidbody force applied to one side of the
Object. That Cause non realistic behaviors or motions.

Character controller can fix it. It is not use a force to the object. That moves it.
But you must change the height and radius of Character controller.

To fix the collision bug. Read the offline documentation came with unity here
/Editor/Data/Documentation/en/Manual/class-CharacterController.html
This is also Available Online