So im just trying to make a ball move with constant velocity in the x direction, the thing is when i write a certain velocity it will work normally:
public Rigidbody thisRigidbody;
void Start () {
thisRigidbody = GetComponent<Rigidbody>();
}
void FixedUpdate () {
thisRigidbody.velocity = new Vector3(5, thisRigidbody.velocity.y, thisRigidbody.velocity.z);
}
But i want to modify that velocity through a float variable (playerSpeed):
public float playerSpeed = 0;
public Rigidbody thisRigidbody;
void Start () {
thisRigidbody = GetComponent<Rigidbody>();
}
void FixedUpdate () {
thisRigidbody.velocity = new Vector3(playerSpeed, thisRigidbody.velocity.y, thisRigidbody.velocity.z);
}
the weird thing is even when i use playerSpeed in 0 like in the code, the ball will move in x anyways in a certain velocity, and when i modify the playerSpeed to some other value, it still moves in that velocity,
idk if i’m missing something help guys