Error CS1061 - Error CS0103 - Error CS0165
I'm trying to make a character move and the tutorial had this script, but when I run the code I get these errors ->'Vector2' does not contain a definition for 'GetAxisRaw' and no accessible extension method 'GetAxisRaw' accepting a first argument of type 'Vector2' could be found (are you missing a using directive or an assembly reference?)
->The name 'speedSmoothVelocity' does not exist in the current context
->error CS1061: 'float' does not contain a definition for 'deltaTime' and no accessible extension method 'deltaTime' accepting a first argument of type 'float' could be found (are you missing a using directive or an assembly reference?)
error CS0165: Use of unassigned local variable 'movementInput'
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class CharacterMovement : MonoBehaviour { [SerializeField] private float movementSpeed = 3f; private float currentSpeed = 0f; private float gameSmoothVelocity = 0f; private float speedSmoothTime = 0.1f; private float rotationSpeed = 0.1f; private float gravity = 3f;
private Transform mainCameraTransform = null; private CharacterController controller = null; private Animator animator = null; private void Start() { controller = GetComponent<CharacterController>(); animator = GetComponent<Animator>(); mainCameraTransform = Camera.main.transform; } private void Update() { Move(); } private void Move() { Vector2 movementInput = new Vector2(Input.GetAxisRaw("Horizontal"), movementInput.GetAxisRaw("Vertical")); Vector3 forward = mainCameraTransform.forward; Vector3 right = mainCameraTransform.right; forward.y = 0; right.y = 0; forward.Normalize(); right.Normalize(); Vector3 desiredMoveDirection = (forward * movementInput.y + right * movementInput.x).normalized; Vector3 gravityVector = Vector3.zero; if(controller.isGrounded) { gravityVector.y -= gravity; } if(desiredMoveDirection != Vector3.zero) { transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(desiredMoveDirection), rotationSpeed); } float targetSpeed = movementSpeed * movementInput.magnitude; currentSpeed = Mathf.SmoothDamp(currentSpeed, targetSpeed, ref speedSmoothVelocity, speedSmoothTime); controller.Move(desiredMoveDirection * currentSpeed * speedSmoothTime.deltaTime); controller.Move(gravityVector * Time.deltaTime); } }
Your answer
![](https://koobas.hobune.stream/wayback/20220612225915im_/https://answers.unity.com/themes/thub/images/avi.jpg)