Hello everyone !
I am very new in coding and unity. I have some trouble making my player position following the boat rotation.
For now:
My player can move with Input.GetAxis AND follow the boat position, so if the boat go straight forward there is no problem with that.
If I give a rotation to the boat ( with the Helm object) the boat do a rotation with the helm object as pivot, but the player do not update his position with this rotation…
I would like the player to move freely on the boat as he does already, and his
position to also update with the rotation given to the boat, or just that it look like he did.
Here is one solution I tried,
Calculating the distance between player and helm, and when the player give a rotation to the boat, this rotation is apply the player given is distance to the helm

Here is some of my code for BoatController:
public float helmDirection { get; private set; }
float helmDirection = 0f;
helmDirection = (helmAngle.localEulerAngles.y / 180) - 0.5f;
// Rotation du bateau
transform.Rotate(Vector3.up * rotateSpeed * helmDirection * Time.deltaTime * -1, Space.Self);
// Direction du mouvement
v3Direction = -1f * transform.forward;
// Normaliser la direction
if (v3Direction.magnitude > 1)
{
v3Direction.Normalize();
}
// Calcul du déplacement
v3Move = v3Direction * currentSpeed * Time.deltaTime;
rb.MovePosition(rb.position + v3Move); // Utiliser MovePosition pour un mouvement plus fluide
// Transmettre le mouvement au joueur
boatMove = v3Move;
}
And some of my script for Player_Controller:
{if (dead == false)
{
SC_boatControllerRigidBody boatController = GameObject.FindWithTag("Boat").GetComponent<SC_boatControllerRigidBody>();
boatMove = boatController.boatMove;
if (isImmune)
{
fTimerImmunity += Time.deltaTime;
if (fTimerImmunity >= 3f)
{
isImmune = false;
fTimerImmunity = 0f;
}
}
if (isMoving)
{
v3Direction = new Vector3(Input.GetAxis("Horizontal"), 0, -Input.GetAxis("Vertical"));
if (v3Direction.magnitude > 1)
v3Direction.Normalize();
Vector3 movement = v3Direction * fSpeed * Time.deltaTime;
// Applique le mouvement et la rotation
controller.Move(movement + boatMove);
// Applique la rotation du bateau
transform.rotation = boatController.boatRotation;
}
else if(isMoving == false)
{
controller.Move(boatMove);
transform.rotation = boatController.boatRotation;
}
Note that I tried with the help of CHATGPT I admit
but I didn’t really like his solution.
When trying to create a new Vector , that calculate the distance to helm + boat rotation
and applying in for example
controller.Move(movement + boatMove + offset)
the offset calculated was making my player goes far offscreen
Anyway, don’t hesitate to tell me if you need more info !
And thank you for your help ![]()
PS: looking for alternative solution also