Applying spin to a ball as it moves is preventing it from moving but it still spins.
I'd like to simulate spin when a ball moves.. the code below worked, I then changed my HUD canvas color, and now it just spins in place without movement...makes no sense. Thanks.
void FixedUpdate () {
Move();
initialVelocity = rigidBody.velocity;
}
void Move() {
if (!hasHitObstruction)
{
if (currentSpeed < speed)
{
currentSpeed += acceleration * Time.deltaTime;
} else
{
currentSpeed = speed;
}
Vector3 playerInputVec = new Vector3(-Input.acceleration.x * playerInputSpeedX, 0,
-Input.acceleration.y * playerInputSpeedY) ;
totalPlayerVec = (transform.forward + playerInputVec) * currentSpeed;
rigidBody.MovePosition(transform.position + totalPlayerVec*Time.deltaTime);
}
}
private void Update()
{
transform.Rotate(new Vector3(totalPlayerVec.z,0,totalPlayerVec.x));
}
Comment