Pendulum movement on a flotting character

Hello !
I want to make a pendulum movement on a spherical character.

But with my code the movement is blocking in the left or on the right when I go forward or backward.
Could you help me ?

using UnityEngine;
using System.Collections;

[System.Serializable]
public class Boundary{
    public float xMin, xMax, yMin, yMax;
}

public class toController : MonoBehaviour {

    private Rigidbody rb;
    public float speed;
    public Boundary boundary;
    public float titlt;
    private float rot;
    private int xcoord;

    void Start ()
    {
        rb = GetComponent<Rigidbody>();
    }
       
    void Update()
    {
        xcoord = Mathf.FloorToInt(Input.GetAxis ("Horizontal"));
        if (xcoord % 10 == 0) {
            rot = -1;
        }
        else
        {
            rot = 1;
        }
        rb.rotation = Quaternion.Euler (0,90,rb.velocity.x * titlt * rot);
    }
    void FixedUpdate ()
    {
        float moveHorizontal = Input.GetAxis ("Horizontal");
        float moveVertical = Input.GetAxis ("Vertical");


        Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);

        rb.velocity = (movement*speed);


    }


}

no one ?

If you’re trying to make a vehicle that act similar to flappy bird I find that specifying a range of motion then determining the position with the movement direction is way better than relying on physics.

Cheaper too.

Sorry, I am not well explain. I want to make a movement like this :

I am a beginner.

So a smooth tilt back and forth? First you’ll want a curve that outputs between 0 to 1. I think a sin curve would work, but you can also try a quad-in/quad-out curve for a different look.

float curve = Mathf.Sin(tiltSpeed * Time.time * Mathf.PI * 2f) * 0.5f + 0.5f;

That’s setting up a curve that will go between 0-1, and will repeat at a rate determined by tiltSpeed (2.0 = twice a second).

Then you apply it to the angle:

float angle = Mathf.LerpAngle(startAngle - tiltAmount, startAngle + tiltAmount, curve);

Ah, I see.

You want the outside wing to point away from the vehicle (and the inside wing to point in) on turns.

Yeah, then a hinge would be the way to go.

Sorry to above you, but could you do a detailed explanation ? I try something but I have a lot of error which I don’t understand.