Hello guys, i wrote a simple script for a 2d character movement, but unity is dropp up the Error cs0103 code.
Error code: Assets\2D-Character-Controller-master\Caharcter2DController.cs(28,47): error CS0103: The name ‘movement’ does not exist in the current context
using UnityEngine;
public class Caharcter2DController : MonoBehaviour
{
public float MovementSpeed = 1;
//player must have a rigidbody2D and a box colider
public float moveSpeed = 5f;
// Start is called before the first frame update
private void Start()
{
}
private void Update()
{
{
Jump();
Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0f, 0f);
transform.position += movement * Time.deltaTime * moveSpeed;
}
{
var methodmovement = Input.GetAxis("Horizontal");
transform.position += new Vector3(movement,0, 0) * Time.deltaTime * MovementSpeed;
}
}
void Jump()
{
if (Input.GetButtonDown("Jump"))
{
gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(0f, 5f), ForceMode2D.Impulse);
}
}
}
[/ICODE]