Help, my movement script is not working!

I’m trying to make my bean guy moving but he’s not. I’m unsure if I did something wrong in the script or did something wrong in Unity. Also this is my first time using the forums so sorry for the formatting…

Using:
C# Coding
Character Controller

Context:
3rd Person Movement
Keeping each part of code sperate (e.g. Camera and Movement are in separate scripts)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Movement : MonoBehaviour
{
        public CharacterController controller;

    // Movement Modifiers
    private float speed;
    public float speedWalk = 5f;
    public float speedRun = 10f;
    Vector3 velocity;

    void Update()
        {
            // Movement Code
            float horizontal = Input.GetAxisRaw("Horizontal");
            float vertical = Input.GetAxisRaw("Vertical");
            Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;

            // Walk and Run Statements
            if (Input.GetKey(KeyCode.LeftShift))
            {
                speed = speedWalk;
            }
            else
            {
                speed = speedRun;
            }
        }
    }

Hi and welcome!

This is a good first post, really. You even used code tags.
Refreshing to see someone actually care about people understanding their question haha :smile:

As for your actual question, the only thing you are missing it to actually apply the calculated positionchange.

transform.position += direction * speed * Time.deltaTime;

Currently you decide on which speed to use, and what direction to go in, but you never use these values.

you never set the new direction to the controller. You need soemthing like:

controller.Move(direction*speed* Time.deltaTime);

on line 32. But then your character will walk automatically.

Here is an short and easy example for movement, if you take that you can just update it with you check if shift is pressed:

Thanks for the help guys, after applying the missing line it works!