AddForce Stopped Working After Update to Unity 5

Well, it seems as though my little script stopped working after the update to Unity 5. This may very well be a simple problem…again, so I’ll give you some details on how everything’s set up.

Kinematic is off

Gravity is on and set to y -1e-05

The object is awake.

There are about half a dozen colliders overlapping the ball, however most of them are set to trigger except for the collider that the ball rests on.

When addForce is applied, the ball moves for 1 frame and the velocity shows a vector other than zero. After the first frame, the vector returns to (0, 0, 0).

Here’s the code. Thanks in advance for all of your help.

#pragma strict

var GravityObject : Transform;
var GravityState : boolean;
var InitialVelocity : float;
var Ship : Collider;

internal var MouseIsDown : boolean;

function Start () {

	transform.position = GravityObject.position;
}

function Update () {
	
	if (GravityState) transform.position = GravityObject.position;
	
	if (Input.GetMouseButtonDown(0)) MouseDown();
	
	if (Input.GetMouseButtonUp(0)) MouseUp();
	
	print(GetComponent.<Rigidbody>().IsSleeping());
}

function MouseDown () {

	var Raycast : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    var TheHit : RaycastHit;
    
    if (Ship.Raycast(Raycast, TheHit, 100.0)) {
    
        MouseIsDown = true;
    }
}

function MouseUp () {

	if (MouseIsDown && GravityState) {
	
		GravityState = false;
		MouseIsDown = false;
		
		GetComponent.<Rigidbody>().AddForce(Vector3.up * InitialVelocity, ForceMode.Impulse);
	}
}

Found the answer just in case you all have this problem. I had an animator attached that faded the material in. On the animator was ‘Apply Root Motion.’ That has always been checked and never caused a problem before. Unchecking it fixed the problem.

I would like to state for the record that once I ask a question on here, I end up fixing it approximately an hour later :smiley:

I mean, I could work on it for days, and right when I post the question, BOOM, fixed.