so ı am a total noob and trying to learn C# (ı basicly cant but anyways) and ı find a tutorial about 2D games and basic C# coding. ı am trying to add jumping to my character bu its not working. (Assets\Scripts\Player.cs(85,64): error CS0117: ‘ForceMode2D’ does not contain a definition for ‘Inpulse’) is the error ı am getting and this is the code:
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using UnityEngine;
using Debug = UnityEngine.Debug;
public class Player : MonoBehaviour { [SerializeField] private float moveForce = 10f; [SerializeField] private float jumpForce = 11f;
private float movementX;
[SerializeField]
private Rigidbody2D rb;
private Animator anim;
private SpriteRenderer sr;
private string WALK_ANIMATİON = “walk”;
private void Awake()
{
rb = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
sr = GetComponent<SpriteRenderer>();
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
PlayerMoveKeyboard();
AnimatePlayer();
}
private void FixedUpdate()
{
PlayerJump();
}
void PlayerMoveKeyboard()
{
movementX = Input.GetAxisRaw(“Horizontal”); // getaxis yavaşça ilerler yani 0, 0.1, 0.2… GetAxisRax ise direk ilerler yani 0,1,2,3 …
transform.position += new Vector3(movementX, 0f, 0f) * Time.deltaTime * moveForce;
}
void AnimatePlayer()
{
//we are going to the right side
if(movementX > 0)
{
anim.SetBool(WALK_ANIMATİON, true);
sr.flipX = false;
}
//we are going to the left side
else if (movementX < 0)
{
anim.SetBool(WALK_ANIMATİON, true);
sr.flipX = true;
}
else
{
anim.SetBool(WALK_ANIMATİON, false);
}
}
void PlayerJump() { if (Input.GetButtonDown(“Jump”)) { rb.AddForce(new Vector2(0f, jumpForce), ForceMode2D.Inpulse); } }
}