It says "error CS1003: Syntax error, ‘,’ expected
here’s my code (anybody know how to fix this)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class charactercontroller : MonoBehaviour
{
Then the improved version for not allocating memory every update. I left the last velocity line as it is but you probably want to use something else other than setting velocity of rigidbody directly. I set the vectors to zero at the beginning in case you want to take away control from the player. For example in menus. Just add a if statement with a return to quit early and still setting the values to zero.
Vector2 is a struct, and not a class. So in this scenario “new” is a syntaxic sugar and no allocation is taking place. There’s no reason to move it outside of function.