I have a sphere with rigid body, (Is Kinematic = False) and Configurable Joint (Configured in World Space = True); using AddForce(0, 500, 0). The sphere’s movement still depends on it’s rotation.
#pragma strict
var moveSpeedX = 15;
var maxSpeedX = 15;
var baseSpeed = 0;
var jumpForce1 = 450.00;
var jumpForce2 = 200.00;
private var doubleJump : boolean = true;
private var grounded : boolean = false;
function Update()
{
if(Physics.Raycast(transform.position, -transform.up, 1)) {
grounded = true;
doubleJump = true;
} else
grounded = false;
if(Input.GetButtonDown("Jump")) {
if(grounded) {
rigidbody.AddForce(0, jumpForce1, 0);
}
else if(doubleJump) {
doubleJump = false;
transform.rigidbody.AddForce(0, jumpForce2, 0);
}
}
if(Input.GetKey(KeyCode.LeftArrow)) {
if (transform.rigidbody.velocity.x > -maxSpeedX) {
transform.rigidbody.velocity.x = transform.rigidbody.velocity.x - (2*moveSpeedX) *Time.deltaTime;
} else {
transform.rigidbody.velocity.x = -maxSpeedX;
}
}
if(Input.GetKey(KeyCode.RightArrow)) {
if (transform.rigidbody.velocity.x < maxSpeedX) {
transform.rigidbody.velocity.x = transform.rigidbody.velocity.x + (2*moveSpeedX) *Time.deltaTime;
} else {
transform.rigidbody.velocity.x = maxSpeedX;
}
}
}
Also tried using: rigidbody.AddForceAtPosition(myForward * 1000.0, rigidbody.worldCenterOfMass); That didn’t work either. Sorry for question that a million noobs like me have already asked, but I can’t get it to work.