# Unity3D RigidBody adding force diagonally (x,y,0) results in two separate movements instead of one diagonal movement?

The intentions of this function are to utilize the RigidBody component from a "target" object and clear its force while applying a diagonal force in the direction upwards and away from the side they are facing. I have omitted the portion in which detects the other direction for the sake of simplicity in reading the function as I've been testing this function while the user faces the right-hand direction.

Variables:

• target refers to the other object currently in the scene
• targBody refers to the RigidBody component of the target object
damage refers to the current damage integer of the object.
The damage used in this instance is from the target object
facingRight refers to a bool in which is true whenever the current object is facing the right-hand direction.

    public void Damage() {
targBody.velocity = Vector3.zero;
if(facingRight) {
Vector3 newVel = new Vector3(target.GetComponent().damage/16, target.GetComponent().damage/16, 0);
print("Stuff");
}
target.GetComponent().damage+=3;
}

For some reason, when I apply the force, the target object doesn't move diagonally. Instead, it moves horizontally before moving vertically; however, for some strange reason the horizontal speed is always greater than the vertical speed as it goes so fast that it nearly teleports!

I'm not sure if this error happens because of a coding problem on my part that I'm just not recognizing or if it's a problem with RigidBody in which I need to use a workaround for.
Anyone have any ideas on what can make this function work the way I want it to?

• Unless you can create a simple example that demonstrates a bug in AddForce, I am rather inclined to assume that the bug is on your side. Recommend simplifying your use case and testing until you figure out what's causing the issue. – rutter Nov 18 '15 at 7:13
• I did not claim that what I'm experiencing is a bug in the engine, I explicitly stated in my question that I'm not sure if it's an error in my coding or an error in my instance of Rigidbody at that point. – RandomAnimeGamer Nov 24 '15 at 21:11

This code in my template project runs perfect and trow object diagonally:

    if (Input.GetKeyDown(KeyCode.Space))
{
rigi.velocity = Vector3.zero;