Player script affecting physics without being called

Hello,
I made a 3D player with a capsule collider, a rigidbody, an animator and a playercontrol script. I also a moving platform.
The problem I am facing is, the player does not stay on the moving platform. However, when i deactive my player script, the player stays on the platform.

Is player script affecting the player’s physics without being called…?
Any ideas of this problem? Here is my script.

    public float runSpeed = 6f;
    public float jumpHeight = 8f;

    Rigidbody rb;
    Animator anim;

    bool facingRight;
    float distToGround;

    void Start()
    {
        rb = GetComponent<Rigidbody>();
        anim = GetComponent<Animator>();
        facingRight = true;
    }

    void FixedUpdate()
    {
        float move = Input.GetAxis("Horizontal");

        if (move != 0f) anim.SetBool("isRunning", true);
        else if (move == 0f) anim.SetBool("isRunning", false);

        rb.velocity = new Vector3(move * runSpeed, rb.velocity.y, 0);

        if (Input.GetButton("Jump"))
        {
            anim.SetTrigger("isJumping");
            rb.velocity = new Vector3(rb.velocity.x, jumpHeight, 0);
        }

        if (move > 0 && !facingRight) Flip();
        else if (move < 0 && facingRight) Flip();
    }

    bool isGrounded() { return Physics.Raycast(transform.position, -Vector3.up, distToGround + 0.1f); }

    void Flip()
    {
        facingRight = !facingRight;
        Vector3 theScale = transform.localScale;
        theScale.z *= -1;
        transform.localScale = theScale;
    }
}

I’m a little confused by the claim your script isn’t being called. You are using the FixedUpdate function which is called every physics frame…

line 24. Your script is directly changing the rigidbody’s velocity. Since it’s a direct assignment (and not an additive assignment or anything else) any other physics interaction isn’t going to be allowed to make any affect.

Ah I see. I commented out line 24, and now it works! :smile:
Thanks for your help!