First that is a 2D game.I made a rotating water mill. When I put my character on top of that. Character does not rotate like it should. It does not turn with water mill and trying to save its position. How can I fix it?
I tried to add Physic materials and some effectors.
////Thats movement code
void FixedUpdate()
{
if( (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow)) && OnPlatform )
{
OnPlatform = false;
rb.velocity = Vector2.up * JumpForce;
}
float move = Input.GetAxisRaw("Horizontal") * MovementSpeed;
if( canWalk && move != 0 )
{
rb.velocity = new Vector2(move,rb.velocity.y);
}
}
I want my rotating surface and player rotate normal like in real world.
One solution would be to make the player a child object of the water mill while he stands on it. But that he then no longer is a child object of it when not standing on it.
Child objects get affected by their parents rotation, scaling and position. So this would rotate the player.
Just use the transform.SetParent(watermillTransform) method on the players transform. Set it to null when he needs to have no parent.