I have a set up where the ground and the player move with physics and a stationary camera.
I want the ground to move faster when the player is getting further away making it look that the player is moving faster without getting further away from the camera.
The way I first thought was to just add the player velocity to the ground velocity, since velocity doesn't care about mass, and set the player velocity to 0.
On the player script:
public void MovePlayer(Vector3 force) { rb.AddForce(force, ForceMode.Force); } private void FixedUpdate() { if (rb.position.z > 10) { PlatformManager.PlayerVelocity = rb.velocity.z; rb.velocity = new Vector3(rb.velocity.x, rb.velocity.y, 0); } else { PlatformManager.PlayerVelocity = 0; } } On the ground script:
//On the fixed update if (playerVelocity > 0) { rb.velocity = (Vector3.back * speedMultiplier) - new Vector3(0, 0, playerVelocity); } else { rb.velocity = Vector3.back * speedMultiplier; } Although this way the player stops at the set limit, because in the next frame its velocity is 0 and the ground velocity is back to regular.
So how could I achieve this? Do I need to calculate manually the velocity that would result in the player movement (with the force in MovePlayer) and set it to the ground? I can't use the force on the ground due to its mass difference.